2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "dssourcepin.h"
21 #include "dssourcefilter.h"
25 DsSourcePin::DsSourcePin(DsSourceFilter *pFilter,
26 CCritSec *pLock,HRESULT *phr,LPCWSTR pName,bool audio):
27 CBaseOutputPin(NAME("dssourcepin"),pFilter,pLock,phr,pName)
34 DsSourcePin::~DsSourcePin()
40 HRESULT DsSourcePin::GetMediaType(int iPosition, CMediaType *pmt)
\r
44 pmt->InitMediaType();
\r
47 pmt->SetType(&MEDIATYPE_Audio);
\r
48 MPEG1WAVEFORMAT wfe;
\r
49 ZeroMemory(&wfe,sizeof(wfe));
\r
51 wfe.wfx.nSamplesPerSec=48000;
\r
52 wfe.wfx.nChannels=2;
\r
53 wfe.wfx.nAvgBytesPerSec=32000;
\r
54 wfe.wfx.nBlockAlign=768;
\r
55 wfe.wfx.wFormatTag=WAVE_FORMAT_MPEG;
\r
57 wfe.dwHeadBitrate=256000;
\r
58 wfe.fwHeadMode=ACM_MPEG_STEREO;
\r
59 wfe.fwHeadModeExt=1;
\r
60 wfe.wHeadEmphasis=1;
\r
61 wfe.fwHeadFlags=ACM_MPEG_ID_MPEG1 |ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT;
\r
62 pmt->SetSubtype(&MEDIASUBTYPE_MPEG2_AUDIO);
\r
63 pmt->SetFormatType(&FORMAT_WaveFormatEx);
\r
64 pmt->SetFormat((BYTE*)&wfe,sizeof(wfe));
\r
65 pmt->SetSampleSize(0);
\r
70 hr=VFW_S_NO_MORE_ITEMS ;
\r
73 if (iPosition == 0) {
\r
74 pmt->SetType(&MEDIATYPE_Video);
\r
76 pmt->SetSubtype(&MEDIASUBTYPE_MPEG2_VIDEO);
\r
77 pmt->SetFormatType(&FORMAT_MPEG2Video);
\r
80 ZeroMemory(&hdr,sizeof(hdr));
\r
81 hdr.dwProfile=AM_MPEG2Profile_Main;
\r
82 hdr.dwLevel=AM_MPEG2Level_Main;
\r
83 hdr.hdr.bmiHeader.biSize = sizeof(hdr.hdr.bmiHeader);
\r
84 hdr.hdr.bmiHeader.biWidth = 720;
\r
85 hdr.hdr.bmiHeader.biHeight = 568;
\r
86 pmt->SetFormat((BYTE*)&hdr,sizeof(hdr));
\r
88 hr=VFW_S_NO_MORE_ITEMS;
\r
95 HRESULT DsSourcePin::CheckMediaType(const CMediaType *pmt)
\r
100 bool subtype=false;
\r
101 #if 0 /* For future demands ac3 */
\r
102 subtype=pmt->subtype==(MEDIASUBTYPE_DOLBY_AC3);
\r
104 subtype=(pmt->subtype==(MEDIASUBTYPE_MPEG2_AUDIO));
\r
105 if (pmt->majortype==MEDIATYPE_Audio && subtype) {
\r
111 if (pmt->majortype==MEDIATYPE_Video &&
\r
112 pmt-> subtype==MEDIASUBTYPE_MPEG2_VIDEO) {
\r
121 HRESULT DsSourcePin::DecideBufferSize(IMemAllocator *pa,ALLOCATOR_PROPERTIES *all_pp){
\r
123 CAutoLock al(m_pFilter->GetLock());
\r
124 CheckPointer(pa, E_POINTER);
\r
125 CheckPointer(all_pp, E_POINTER);
\r
127 if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024)
\r
129 //all_pp->cBuffers = 300;//old
\r
130 all_pp->cBuffers = 10;
\r
131 all_pp->cbBuffer = 64*1024;
\r
134 if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024)
\r
136 //all_pp->cBuffers = 300;//old
\r
137 all_pp->cBuffers = 30;
\r
138 all_pp->cbBuffer = 64*1024;
\r
142 ALLOCATOR_PROPERTIES all_pp_cur;
\r
143 hr =pa->SetProperties(all_pp,&all_pp_cur);
\r
148 if (all_pp_cur.cbBuffer*all_pp_cur.cBuffers < all_pp->cBuffers*all_pp->cbBuffer)
\r