Changeset 3507
- Timestamp:
- Apr 7, 2011 8:27:27 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c
r3505 r3507 487 487 static pj_status_t create_filter_graph(pjmedia_dir dir, 488 488 unsigned id, 489 pj_bool_t use_def_size, 490 pj_bool_t use_def_fps, 489 491 struct dshow_factory *df, 490 492 struct dshow_stream *strm, … … 675 677 } 676 678 video_info = (VIDEOINFOHEADER *) mediatype->pbFormat; 677 video_info->bmiHeader.biWidth = vfd->size.w; 678 video_info->bmiHeader.biHeight = vfd->size.h; 679 if (vfd->fps.num != 0) 679 if (!use_def_size) { 680 video_info->bmiHeader.biWidth = vfd->size.w; 681 video_info->bmiHeader.biHeight = vfd->size.h; 682 } 683 if (!use_def_fps && vfd->fps.num != 0) 680 684 video_info->AvgTimePerFrame = (LONGLONG) (10000000 * 681 685 (double)vfd->fps.denum / … … 695 699 hr = IFilterGraph_ConnectDirect(graph->filter_graph, srcpin, sinkpin, 696 700 mediatype); 701 if (SUCCEEDED(hr)) { 702 pjmedia_format_init_video(&strm->param.fmt, strm->param.fmt.id, 703 video_info->bmiHeader.biWidth, 704 video_info->bmiHeader.biHeight, 705 10000000, 706 (unsigned)video_info->AvgTimePerFrame); 707 } 697 708 698 709 on_error: … … 715 726 } 716 727 728 static void destroy_filter_graph(struct dshow_stream * stream) 729 { 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 } 749 } 750 } 751 717 752 /* API: create stream */ 718 753 static pj_status_t dshow_factory_create_stream( … … 747 782 748 783 status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id, 749 df, strm, &strm->dgraph[ngraph++]); 750 if (status != PJ_SUCCESS) 751 goto on_error; 784 PJ_FALSE, PJ_FALSE, df, strm, 785 &strm->dgraph[ngraph++]); 786 if (status != PJ_SUCCESS) { 787 destroy_filter_graph(strm); 788 /* Try to use default fps */ 789 PJ_LOG(4,(THIS_FILE, "Trying to open dshow dev with default fps")); 790 status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id, 791 PJ_FALSE, PJ_TRUE, df, strm, 792 &strm->dgraph[ngraph]); 793 794 if (status != PJ_SUCCESS) { 795 /* Still failed, now try to use default fps and size */ 796 destroy_filter_graph(strm); 797 /* Try to use default fps */ 798 PJ_LOG(4,(THIS_FILE, "Trying to open dshow dev with default " 799 "size & fps")); 800 status = create_filter_graph(PJMEDIA_DIR_CAPTURE, 801 param->cap_id, 802 PJ_TRUE, PJ_TRUE, df, strm, 803 &strm->dgraph[ngraph]); 804 } 805 806 if (status != PJ_SUCCESS) 807 goto on_error; 808 pj_memcpy(param, &strm->param, sizeof(*param)); 809 } 752 810 753 811 vfd = pjmedia_format_get_video_format_detail(¶m->fmt, PJ_TRUE); … … 758 816 if (param->dir & PJMEDIA_DIR_RENDER) { 759 817 status = create_filter_graph(PJMEDIA_DIR_RENDER, param->rend_id, 760 df, strm, &strm->dgraph[ngraph++]); 818 PJ_FALSE, PJ_FALSE, df, strm, 819 &strm->dgraph[ngraph++]); 761 820 if (status != PJ_SUCCESS) 762 821 goto on_error; … … 895 954 } 896 955 897 898 956 /* API: Destroy stream. */ 899 957 static pj_status_t dshow_stream_destroy(pjmedia_vid_dev_stream *strm) 900 958 { 901 959 struct dshow_stream *stream = (struct dshow_stream*)strm; 902 unsigned i;903 960 904 961 PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); 905 962 906 963 dshow_stream_stop(strm); 907 908 for (i = 0; i < 2; i++) { 909 if (stream->dgraph[i].source_filter) { 910 IBaseFilter_Release(stream->dgraph[i].source_filter); 911 stream->dgraph[i].source_filter = NULL; 912 } 913 if (stream->dgraph[i].rend_filter) { 914 IBaseFilter_Release(stream->dgraph[i].rend_filter); 915 stream->dgraph[i].rend_filter = NULL; 916 } 917 if (stream->dgraph[i].media_filter) { 918 IMediaFilter_Release(stream->dgraph[i].media_filter); 919 stream->dgraph[i].media_filter = NULL; 920 } 921 if (stream->dgraph[i].filter_graph) { 922 IFilterGraph_Release(stream->dgraph[i].filter_graph); 923 stream->dgraph[i].filter_graph = NULL; 924 } 925 } 964 destroy_filter_graph(stream); 926 965 927 966 pj_pool_release(stream->pool);
Note: See TracChangeset
for help on using the changeset viewer.