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)
47 pmt->SetType(&MEDIATYPE_Audio);
49 ZeroMemory(&wfe,sizeof(wfe));
51 wfe.wfx.nSamplesPerSec=48000;
53 wfe.wfx.nAvgBytesPerSec=32000;
54 wfe.wfx.nBlockAlign=768;
55 wfe.wfx.wFormatTag=WAVE_FORMAT_MPEG;
57 wfe.dwHeadBitrate=256000;
58 wfe.fwHeadMode=ACM_MPEG_STEREO;
61 wfe.fwHeadFlags=ACM_MPEG_ID_MPEG1 |ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT;
62 pmt->SetSubtype(&MEDIASUBTYPE_MPEG2_AUDIO);
63 pmt->SetFormatType(&FORMAT_WaveFormatEx);
64 pmt->SetFormat((BYTE*)&wfe,sizeof(wfe));
65 pmt->SetSampleSize(0);
70 hr=VFW_S_NO_MORE_ITEMS ;
74 pmt->SetType(&MEDIATYPE_Video);
76 pmt->SetSubtype(&MEDIASUBTYPE_MPEG2_VIDEO);
77 pmt->SetFormatType(&FORMAT_MPEG2Video);
80 ZeroMemory(&hdr,sizeof(hdr));
81 hdr.dwProfile=AM_MPEG2Profile_Main;
82 hdr.dwLevel=AM_MPEG2Level_Main;
83 hdr.hdr.bmiHeader.biSize = sizeof(hdr.hdr.bmiHeader);
84 hdr.hdr.bmiHeader.biWidth = 720;
85 hdr.hdr.bmiHeader.biHeight = 568;
86 pmt->SetFormat((BYTE*)&hdr,sizeof(hdr));
88 hr=VFW_S_NO_MORE_ITEMS;
95 HRESULT DsSourcePin::CheckMediaType(const CMediaType *pmt)
101 #if 0 /* For future demands ac3 */
102 subtype=pmt->subtype==(MEDIASUBTYPE_DOLBY_AC3);
104 subtype=(pmt->subtype==(MEDIASUBTYPE_MPEG2_AUDIO));
105 if (pmt->majortype==MEDIATYPE_Audio && subtype) {
111 if (pmt->majortype==MEDIATYPE_Video &&
112 pmt-> subtype==MEDIASUBTYPE_MPEG2_VIDEO) {
121 HRESULT DsSourcePin::DecideBufferSize(IMemAllocator *pa,ALLOCATOR_PROPERTIES *all_pp){
123 CAutoLock al(m_pFilter->GetLock());
124 CheckPointer(pa, E_POINTER);
125 CheckPointer(all_pp, E_POINTER);
127 if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024)
129 all_pp->cBuffers = 300;
130 all_pp->cbBuffer = 64*1024;
133 if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024)
135 all_pp->cBuffers = 300;
136 all_pp->cbBuffer = 64*1024;
140 ALLOCATOR_PROPERTIES all_pp_cur;
141 hr =pa->SetProperties(all_pp,&all_pp_cur);
146 if (all_pp_cur.cbBuffer*all_pp_cur.cBuffers < all_pp->cBuffers*all_pp->cbBuffer)