- Timestamp:
- Jun 9, 2011 4:08:47 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c
r3511 r3580 66 66 {PJMEDIA_FORMAT_YUY2, &MEDIASUBTYPE_YUY2} , 67 67 {PJMEDIA_FORMAT_RGB24, &MEDIASUBTYPE_RGB24} , 68 {PJMEDIA_FORMAT_RGB32, &MEDIASUBTYPE_RGB32} ,68 // {PJMEDIA_FORMAT_RGB32, &MEDIASUBTYPE_RGB32} , 69 69 //{PJMEDIA_FORMAT_IYUV, &MEDIASUBTYPE_IYUV} , 70 70 }; … … 114 114 IBaseFilter *rend_filter; 115 115 AM_MEDIA_TYPE *mediatype; 116 } dgraph [2];116 } dgraph; 117 117 118 118 pj_timestamp cap_ts; … … 384 384 385 385 pj_bzero(param, sizeof(*param)); 386 if (di->info.dir & PJMEDIA_DIR_CAPTURE_RENDER) { 387 param->dir = PJMEDIA_DIR_CAPTURE_RENDER; 388 param->cap_id = index; 389 param->rend_id = index; 390 } else if (di->info.dir & PJMEDIA_DIR_CAPTURE) { 386 if (di->info.dir & PJMEDIA_DIR_CAPTURE) { 391 387 param->dir = PJMEDIA_DIR_CAPTURE; 392 388 param->cap_id = index; … … 402 398 /* Set the device capabilities here */ 403 399 param->clock_rate = DEFAULT_CLOCK_RATE; 404 //param->frame_rate.num = DEFAULT_FPS;405 //param->frame_rate.denum = 1;406 400 param->flags = PJMEDIA_VID_DEV_CAP_FORMAT; 407 401 … … 451 445 { 452 446 struct dshow_stream *stream = (struct dshow_stream*)strm; 453 unsigned i;447 HRESULT hr; 454 448 455 449 if (stream->quit_flag) { … … 458 452 } 459 453 460 for (i = 0; i < 2; i++) { 461 if (stream->dgraph[i].csource_filter) { 462 HRESULT hr = SourceFilter_Deliver(stream->dgraph[i].csource_filter, 463 frame->buf, frame->size); 464 465 if (FAILED(hr)) { 466 return hr; 467 } 468 break; 469 } 470 } 454 hr = SourceFilter_Deliver(stream->dgraph.csource_filter, 455 frame->buf, frame->size); 456 if (FAILED(hr)) 457 return hr; 471 458 472 459 return PJ_SUCCESS; … … 728 715 static void destroy_filter_graph(struct dshow_stream * stream) 729 716 { 730 unsigned i; 731 732 for (i = 0; i < 2; i++) { 733 if (stream->dgraph[i].source_filter) { 734 IBaseFilter_Release(stream->dgraph[i].source_filter); 735 stream->dgraph[i].source_filter = NULL; 736 } 737 if (stream->dgraph[i].rend_filter) { 738 IBaseFilter_Release(stream->dgraph[i].rend_filter); 739 stream->dgraph[i].rend_filter = NULL; 740 } 741 if (stream->dgraph[i].media_filter) { 742 IMediaFilter_Release(stream->dgraph[i].media_filter); 743 stream->dgraph[i].media_filter = NULL; 744 } 745 if (stream->dgraph[i].filter_graph) { 746 IFilterGraph_Release(stream->dgraph[i].filter_graph); 747 stream->dgraph[i].filter_graph = NULL; 748 } 717 if (stream->dgraph.source_filter) { 718 IBaseFilter_Release(stream->dgraph.source_filter); 719 stream->dgraph.source_filter = NULL; 720 } 721 if (stream->dgraph.rend_filter) { 722 IBaseFilter_Release(stream->dgraph.rend_filter); 723 stream->dgraph.rend_filter = NULL; 724 } 725 if (stream->dgraph.media_filter) { 726 IMediaFilter_Release(stream->dgraph.media_filter); 727 stream->dgraph.media_filter = NULL; 728 } 729 if (stream->dgraph.filter_graph) { 730 IFilterGraph_Release(stream->dgraph.filter_graph); 731 stream->dgraph.filter_graph = NULL; 749 732 } 750 733 } … … 761 744 pj_pool_t *pool; 762 745 struct dshow_stream *strm; 763 unsigned ngraph = 0;764 746 pj_status_t status; 747 748 PJ_ASSERT_RETURN(param->dir == PJMEDIA_DIR_CAPTURE || 749 param->dir == PJMEDIA_DIR_RENDER, PJ_EINVAL); 765 750 766 751 if (!get_dshow_format_info(param->fmt.id)) … … 777 762 strm->user_data = user_data; 778 763 779 /* Create capture stream here */780 764 if (param->dir & PJMEDIA_DIR_CAPTURE) { 781 765 const pjmedia_video_format_detail *vfd; 782 766 767 /* Create capture stream here */ 783 768 status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id, 784 769 PJ_FALSE, PJ_FALSE, df, strm, 785 &strm->dgraph [ngraph++]);770 &strm->dgraph); 786 771 if (status != PJ_SUCCESS) { 787 772 destroy_filter_graph(strm); … … 790 775 status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id, 791 776 PJ_FALSE, PJ_TRUE, df, strm, 792 &strm->dgraph [ngraph]);777 &strm->dgraph); 793 778 794 779 if (status != PJ_SUCCESS) { … … 801 786 param->cap_id, 802 787 PJ_TRUE, PJ_TRUE, df, strm, 803 &strm->dgraph [ngraph]);788 &strm->dgraph); 804 789 } 805 790 … … 811 796 vfd = pjmedia_format_get_video_format_detail(¶m->fmt, PJ_TRUE); 812 797 strm->cap_ts_inc = PJMEDIA_SPF2(param->clock_rate, &vfd->fps, 1); 813 } 814 815 /* Create render stream here */ 816 if (param->dir & PJMEDIA_DIR_RENDER) { 798 } else if (param->dir & PJMEDIA_DIR_RENDER) { 799 /* Create render stream here */ 817 800 status = create_filter_graph(PJMEDIA_DIR_RENDER, param->rend_id, 818 801 PJ_FALSE, PJ_FALSE, df, strm, 819 &strm->dgraph [ngraph++]);802 &strm->dgraph); 820 803 if (status != PJ_SUCCESS) 821 804 goto on_error; … … 903 886 { 904 887 struct dshow_stream *stream = (struct dshow_stream*)strm; 905 unsigned i;888 HRESULT hr; 906 889 907 890 stream->quit_flag = PJ_FALSE; … … 909 892 stream->rend_thread_exited = PJ_FALSE; 910 893 911 for (i = 0; i < 2; i++) { 912 HRESULT hr; 913 914 if (!stream->dgraph[i].media_filter) 915 continue; 916 hr = IMediaFilter_Run(stream->dgraph[i].media_filter, 0); 917 if (FAILED(hr)) { 918 char msg[80]; 919 if (AMGetErrorText(hr, msg, sizeof(msg))) { 920 PJ_LOG(4,(THIS_FILE, "Error starting media: %s", msg)); 921 } 922 return PJ_EUNKNOWN; 894 hr = IMediaFilter_Run(stream->dgraph.media_filter, 0); 895 if (FAILED(hr)) { 896 char msg[80]; 897 if (AMGetErrorText(hr, msg, sizeof(msg))) { 898 PJ_LOG(4,(THIS_FILE, "Error starting media: %s", msg)); 923 899 } 900 return PJ_EUNKNOWN; 924 901 } 925 902 … … 943 920 pj_thread_sleep(10); 944 921 945 for (i = 0; i < 2; i++) { 946 if (!stream->dgraph[i].media_filter) 947 continue; 948 IMediaFilter_Stop(stream->dgraph[i].media_filter); 949 } 922 IMediaFilter_Stop(stream->dgraph.media_filter); 950 923 951 924 PJ_LOG(4, (THIS_FILE, "Stopping dshow video stream"));
Note: See TracChangeset
for help on using the changeset viewer.