Changeset 3460
- Timestamp:
- Mar 17, 2011 11:27:37 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/simpleua.c
r3435 r3460 102 102 static pjsip_inv_session *g_inv; /* Current invite session. */ 103 103 static pjmedia_stream *g_med_stream; /* Call's audio stream. */ 104 static pjmedia_snd_port *g_snd_port; /* Sound device. */ 105 106 #if PJMEDIA_HAS_VIDEO 104 107 static pjmedia_vid_stream *g_med_vstream; /* Call's video stream. */ 105 static pjmedia_snd_port *g_snd_player; /* Call's sound player */106 static pjmedia_snd_port *g_snd_rec; /* Call's sound recorder. */107 108 static pjmedia_vid_port *g_vid_capturer;/* Call's video capturer. */ 108 109 static pjmedia_vid_port *g_vid_renderer;/* Call's video renderer. */ 109 110 #endif /* PJMEDIA_HAS_VIDEO */ 110 111 111 112 /* … … 374 375 375 376 /* Init video subsystem */ 377 #if PJMEDIA_HAS_VIDEO 376 378 pool = pjmedia_endpt_create_pool(g_med_endpt, "Video subsystem", 512, 512); 377 379 status = pjmedia_video_format_mgr_create(pool, 64, 0, NULL); … … 384 386 PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); 385 387 388 # if PJMEDIA_HAS_FFMPEG_CODEC 386 389 /* Init ffmpeg video codecs */ 387 390 status = pjmedia_codec_ffmpeg_init(NULL, &cp.factory); 388 391 PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); 389 392 # endif /* PJMEDIA_HAS_FFMPEG_CODEC */ 393 394 #endif /* PJMEDIA_HAS_VIDEO */ 390 395 391 396 /* … … 469 474 470 475 /* Get the SDP body to be put in the outgoing INVITE, by asking 471 * media endpoint to create one for us. The SDP will contain all 472 * codecs that have been registered to it (in this case, only 473 * PCMA and PCMU), plus telephony event. 476 * media endpoint to create one for us. 474 477 */ 475 478 status = pjmedia_endpt_create_sdp( g_med_endpt, /* the media endpt */ 476 479 dlg->pool, /* pool. */ 477 MAX_MEDIA_CNT, 480 MAX_MEDIA_CNT, /* # of streams */ 478 481 g_sock_info, /* RTP sock info */ 479 482 &local_sdp); /* the SDP result */ … … 548 551 dump_pool_usage(THIS_FILE, &cp); 549 552 550 /* Destroy stream */ 551 if (g_med_stream) 552 pjmedia_stream_destroy(g_med_stream); 553 if (g_med_vstream) 554 pjmedia_vid_stream_destroy(g_med_vstream); 555 556 /* Destroy audio ports */ 557 if (g_snd_player) 558 pjmedia_snd_port_destroy(g_snd_player); 559 if (g_snd_rec) 560 pjmedia_snd_port_destroy(g_snd_rec); 553 /* Destroy audio ports. Destroy the audio port first 554 * before the stream since the audio port has threads 555 * that get/put frames to the stream. 556 */ 557 if (g_snd_port) 558 pjmedia_snd_port_destroy(g_snd_port); 561 559 562 560 /* Destroy video ports */ 561 #if PJMEDIA_HAS_VIDEO 563 562 if (g_vid_capturer) 564 563 pjmedia_vid_port_destroy(g_vid_capturer); 565 564 if (g_vid_renderer) 566 565 pjmedia_vid_port_destroy(g_vid_renderer); 566 #endif 567 568 /* Destroy streams */ 569 if (g_med_stream) 570 pjmedia_stream_destroy(g_med_stream); 571 #if PJMEDIA_HAS_VIDEO 572 if (g_med_vstream) 573 pjmedia_vid_stream_destroy(g_med_vstream); 574 #endif 567 575 568 576 /* Destroy media transports */ … … 573 581 574 582 /* Deinit ffmpeg codec */ 583 #if PJMEDIA_HAS_FFMPEG_CODEC 575 584 pjmedia_codec_ffmpeg_deinit(); 585 #endif 576 586 577 587 /* Deinit pjmedia endpoint */ … … 846 856 pjmedia_stream_get_port(g_med_stream, &media_port); 847 857 848 849 850 /* Create a sound Player device and connect the media port to the 851 * sound device. 852 */ 853 status = pjmedia_snd_port_create_player( 854 inv->pool, /* pool */ 855 -1, /* sound dev id */ 856 PJMEDIA_PIA_SRATE(&media_port->info),/* clock rate */ 857 PJMEDIA_PIA_CCNT(&media_port->info),/* channel count */ 858 PJMEDIA_PIA_SPF(&media_port->info), /* samples per frame*/ 859 PJMEDIA_PIA_BITS(&media_port->info),/* bits per sample */ 860 0, /* options */ 861 &g_snd_player); 858 /* Create sound port */ 859 pjmedia_snd_port_create(inv->pool, 860 PJMEDIA_AUD_DEFAULT_CAPTURE_DEV, 861 PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV, 862 PJMEDIA_PIA_SRATE(&media_port->info),/* clock rate */ 863 PJMEDIA_PIA_CCNT(&media_port->info),/* channel count */ 864 PJMEDIA_PIA_SPF(&media_port->info), /* samples per frame*/ 865 PJMEDIA_PIA_BITS(&media_port->info),/* bits per sample */ 866 0, 867 &g_snd_port); 868 862 869 if (status != PJ_SUCCESS) { 863 app_perror( THIS_FILE, "Unable to create sound p layer", status);870 app_perror( THIS_FILE, "Unable to create sound port", status); 864 871 PJ_LOG(3,(THIS_FILE, "%d %d %d %d", 865 872 PJMEDIA_PIA_SRATE(&media_port->info),/* clock rate */ … … 871 878 } 872 879 873 status = pjmedia_snd_port_connect(g_snd_player, media_port); 874 875 876 /* Create a sound recorder device and connect the media port to the 877 * sound device. 878 */ 879 status = pjmedia_snd_port_create_rec( 880 inv->pool, /* pool */ 881 -1, /* sound dev id */ 882 PJMEDIA_PIA_SRATE(&media_port->info),/* clock rate */ 883 PJMEDIA_PIA_CCNT(&media_port->info),/* channel count */ 884 PJMEDIA_PIA_SPF(&media_port->info), /* samples per frame*/ 885 PJMEDIA_PIA_BITS(&media_port->info),/* bits per sample */ 886 0, /* options */ 887 &g_snd_rec); 888 if (status != PJ_SUCCESS) { 889 app_perror( THIS_FILE, "Unable to create sound recorder", status); 890 return; 891 } 892 893 status = pjmedia_snd_port_connect(g_snd_rec, media_port); 880 status = pjmedia_snd_port_connect(g_snd_port, media_port); 894 881 895 882 … … 898 885 * the port directly to a renderer/capture video device. 899 886 */ 887 #if PJMEDIA_HAS_VIDEO 900 888 if (local_sdp->media_count > 1) { 901 889 pjmedia_vid_stream_info vstream_info; 902 890 pjmedia_vid_port_param vport_param; 891 892 pjmedia_vid_port_param_default(&vport_param); 903 893 904 894 /* Create stream info based on the media video SDP. */ … … 919 909 * media socket that we created earlier. 920 910 */ 921 status = pjmedia_vid_stream_create(g_med_endpt, inv->dlg->pool,922 &vstream_info, g_med_transport[1],923 NULL,&g_med_vstream);911 status = pjmedia_vid_stream_create(g_med_endpt, NULL, &vstream_info, 912 g_med_transport[1], NULL, 913 &g_med_vstream); 924 914 if (status != PJ_SUCCESS) { 925 915 app_perror( THIS_FILE, "Unable to create video stream", status); … … 933 923 return; 934 924 } 935 936 925 937 926 if (vstream_info.dir & PJMEDIA_DIR_DECODING) { … … 945 934 } 946 935 947 /* Get renderer format from decoding format in stream info */ 948 pjmedia_format_copy(&vport_param.vidparam.fmt, 949 &vstream_info.codec_param->dec_fmt); 936 /* Get video stream port for decoding direction */ 937 pjmedia_vid_stream_get_port(g_med_vstream, PJMEDIA_DIR_DECODING, 938 &media_port); 939 940 /* Set format */ 941 pjmedia_format_copy(&vport_param.vidparam.fmt, 942 &media_port->info.fmt); 950 943 vport_param.vidparam.dir = PJMEDIA_DIR_RENDER; 951 944 vport_param.active = PJ_TRUE; … … 959 952 return; 960 953 } 961 962 /* Get video stream port for decoding direction */963 pjmedia_vid_stream_get_port(g_med_vstream, PJMEDIA_DIR_DECODING,964 &media_port);965 954 966 955 /* Connect renderer to media_port */ … … 985 974 } 986 975 987 /* Get renderer capturer from encoding format in stream info */ 976 /* Get video stream port for decoding direction */ 977 pjmedia_vid_stream_get_port(g_med_vstream, PJMEDIA_DIR_ENCODING, 978 &media_port); 979 980 /* Get capturer format from stream info */ 988 981 pjmedia_format_copy(&vport_param.vidparam.fmt, 989 &vstream_info.codec_param->enc_fmt); 990 991 /* Capturer format ID should be copied from decoder format ID? */ 992 vport_param.vidparam.fmt.id = vstream_info.codec_param->dec_fmt.id; 982 &media_port->info.fmt); 993 983 vport_param.vidparam.dir = PJMEDIA_DIR_CAPTURE; 994 984 vport_param.active = PJ_TRUE; … … 1003 993 } 1004 994 1005 /* Get video stream port for decoding direction */1006 pjmedia_vid_stream_get_port(g_med_vstream, PJMEDIA_DIR_ENCODING,1007 &media_port);1008 1009 995 /* Connect capturer to media_port */ 1010 996 status = pjmedia_vid_port_connect(g_vid_capturer, media_port, … … 1035 1021 } 1036 1022 } 1023 #endif /* PJMEDIA_HAS_VIDEO */ 1037 1024 1038 1025 /* Done with media. */
Note: See TracChangeset
for help on using the changeset viewer.