MuxRenderer 的实现
来源:互联网 发布:介绍一种网络新技术 编辑:程序博客网 时间:2024/05/17 01:39
#ifndef __AMCMUXER_H__
#define __AMCMUXER_H__
#include <streams.h>
#include <amextra.h>
#include "amc_strmif.h"
class CAMCMuxInputPin;
class CAMCMuxRenderer;
// AMCMuxer class
class CAMCMuxRenderer : public CBaseFilter, public IFileSinkFilter2, public IAMFilterMiscFlags, public IAMCRecord
{
friend class CAMCMuxInputPin;
public:
// Constructor
CAMCMuxRenderer( TCHAR* pszName, LPUNKNOWN pUnk, HRESULT *phr, REFCLSID clsid);
virtual ~CAMCMuxRenderer();
DECLARE_IUNKNOWN
// Overriden to say what interfaces we support where
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
#ifdef DEBUG
ULONG STDMETHODCALLTYPE NonDelegatingRelease();
#endif
// Pin enumeration
virtual CBasePin * GetPin(int n);
virtual int GetPinCount();
virtual HRESULT CheckInputType (const CMediaType * mtIn);
// Open and close the file as necessary
virtual STDMETHODIMP Run(REFERENCE_TIME tStart);
virtual STDMETHODIMP Pause();
virtual STDMETHODIMP Stop();
// receive sample
virtual STDMETHODIMP Receive(IMediaSample *pSample, const GUID* pMediaType);
// Implements the IFileSinkFilter interface
virtual STDMETHODIMP SetFileName(LPCOLESTR pszFileName,const AM_MEDIA_TYPE *pmt);
virtual STDMETHODIMP GetCurFile(LPOLESTR * ppszFileName,AM_MEDIA_TYPE *pmt);
virtual HRESULT STDMETHODCALLTYPE SetMode(DWORD dwFlags);
virtual HRESULT STDMETHODCALLTYPE GetMode( DWORD* pdwFlags);
// IAMFilterMiscFlags
virtual ULONG STDMETHODCALLTYPE GetMiscFlags(void);
//IAMCRecord interface
STDMETHODIMP SetCallback( PFNRECORDCALLBACK pfnRecordCallback, LONG lUserData);
HRESULT Callback();
protected:
WCHAR* m_pFileName;
CCritSec m_csFilter;
CCritSec m_csReceive;
CAMCMuxInputPin* m_pAudioPin;
CAMCMuxInputPin* m_pVideoPin;
WAVEFORMATEX m_vf;
LONG m_lUserData;
DWORD m_dwRecordStatus;
DWORD m_dwRecordSize;
DWORD m_dwRecordTime;
DWORD m_dwDumpSize;
DWORD m_dwAudioTime;
DWORD m_dwVideoTime;
PFNRECORDCALLBACK m_pFnCallback;
DWORD m_dwMode;
};
// Pin object
class CAMCMuxInputPin : public CRenderedInputPin, public CBaseStreamControl
{
public:
CAMCMuxInputPin( TCHAR* pObjectName,
CBaseFilter *pFilter,
CCritSec *pLock,
HRESULT *phr);
~CAMCMuxInputPin();
DECLARE_IUNKNOWN
// Overriden to say what interfaces we support where
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
// Do something with this media sample
virtual STDMETHODIMP Receive(IMediaSample *pSample);
virtual STDMETHODIMP EndOfStream(void);
virtual STDMETHODIMP ReceiveCanBlock();
//check if it is endofstream
virtual BOOL IsEndOfStream();
// Check if the pin can support this specific proposed type and format
virtual HRESULT CheckMediaType(const CMediaType* mtIn);
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
virtual HRESULT AddMediaType(const CMediaType *pMediaType);
// Track NewSegment
STDMETHODIMP NewSegment(REFERENCE_TIME tStart,
REFERENCE_TIME tStop,
double dRate);
// Default handling for BeginFlush - call at the beginning
// of your implementation (makes sure that all Receive calls
// fail). After calling this, you need to free any queued data
// and then call downstream.
STDMETHODIMP BeginFlush(void);
// default handling for EndFlush - call at end of your implementation
// - before calling this, ensure that there is no queued data and no thread
// pushing any more without a further receive, then call downstream,
// then call this method to clear the m_bFlushing flag and re-enable
// receives
STDMETHODIMP EndFlush(void);
protected:
// List of media types we support
CGenericList<CMediaType> m_lTypes;
CAMCMuxRenderer* m_pMuxRenderer;
};
#endif //__AMCMUXER_H__
//------------------------------------------------------------------------------
// File: Mp4MuxerRender.h
//
// Desc: DirectShow sample code - definitions for dump renderer.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
#ifndef __MP4_MUXERRENDER_H__
#define __MP4_MUXERRENDER_H__
#include <streams.h>
#include <amextra.h>
class CMP4Muxer ;//the class to write a .mp4/.3gp/.3g2 file
class CMP4Renderer : public CAMCMuxRenderer
{
public:
static CUnknown * WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr);
// Constructor
CMP4Renderer( LPUNKNOWN pUnk, HRESULT *phr);
~CMP4Renderer();
// Pin enumeration
CBasePin * GetPin(int n);
int GetPinCount();
HRESULT CheckInputType (const CMediaType * mtIn);
// Open and close the file as necessary
STDMETHODIMP Stop();
STDMETHODIMP JoinFilterGraph(IFilterGraph * pGraph, LPCWSTR pName);
// receive sample
STDMETHODIMP Receive(IMediaSample *pSample, const GUID* pMediaType);
private:
HRESULT CheckVideoInput(const CMediaType* mtIn);
HRESULT CheckAudioInput(const CMediaType* mtIn);
HRESULT GetRegistryInfo();
private:
CMP4Muxer* m_pMuxer;
MEDIAAUDIOINFO* m_pAudioInfo;
MEDIAVIDEOINFO* m_pVideoInfo;
REFERENCE_TIME m_tLast;
DWORD m_dwWidth;
DWORD m_dwHeight;
DWORD m_dwRotate;
// Following data member is used to solve a problem in DMO.
// In DMO (Picture&Video app), when user pause the video capture process,
// actually the app does not call the pause function, just do not pass the raw data.
// But the stream time is till go on. So when the capture process is resumed,
// the time stamp will skip a long time. It is okey for audio steeam for the muxer just
// dump the audio data according to the date durationg. But for video stream, that cause
// a big problem.
DWORD m_dwSampleA; //audio samples that have been dumped
DWORD m_dwStartA; //audio stream start time. Note: the time stamp of first audio sample may not start from zero.
LONG m_lDeltaA; //dela time
DWORD m_dwSampleV; //video samples that have been dumped
};
class CMP4Muxer
{
public:
CMP4Muxer();
~CMP4Muxer();
HRESULT DumpVideoFrame(PBYTE pbData, LONG lDataLength, BOOL bSyncFrame, DWORD dwTimeStamp);
HRESULT DumpAudioFrame(PBYTE pbData, LONG lDataLength, DWORD dwDuration, DWORD dwTimeSpan);
// Open and write to the file
HRESULT OpenFile(TCHAR* szFileName);
HRESULT CloseFile();
HRESULT SetAudioInfo(MEDIAAUDIOINFO* pAudioInfo);
HRESULT SetVideoInfo(MEDIAVIDEOINFO* pVideoInfo);
BOOL HasEnoughSpace();
DWORD GetDumpSize();
public:
MMP4HANDLE m_hMux;
MEDIAAUDIOINFO* m_pAudioInfo;
MEDIAVIDEOINFO* m_pVideoInfo;
BOOL m_bHasAudio;
BOOL m_bHasVideo;
LONG m_lVideoTime;
LONG m_lAudioTime;
BYTE* m_pAudioBuf;
DWORD m_dwAudOffset;
DWORD m_dwAudDuration;
LONG m_lAudDelTime;
DWORD m_dwStartTime;
BOOL m_bVideoRec;
TCHAR* m_pFileName;
};
#endif//__MP4_MUXERRENDER_H__
- MuxRenderer 的实现
- 三子棋的实现的实现的实现
- JAVA实现的时钟实现
- 模态框的的实现
- 杀毒软件的简单实现的简单实现
- android的实现电话号码的实现
- 音频的实现音乐声音的实现
- malloc的实现、内存池的实现
- 异形窗体的实现
- 个性化的分页实现
- ASP数据库连接的实现
- Struts单选框的实现
- 梅西迭代算法的实现
- 翻页功能的实现
- Struts,MVC 的实现
- 实现JavaScript的继承
- 接口的显示实现
- TTerm的实现( 一)
- Class DynaValidatorForm
- 学习管理!!中国历史上最经典的7个智慧案例
- 探讨System.Net.Mail命名空间中的类
- 最近拿到一本好书The Old New Thing!
- .NET Romoting 学习总结(一)——Remoting技术之激活模式全接触
- MuxRenderer 的实现
- MySQL与Access之语法区别
- VB写日志类
- .NET Romoting 学习总结(二)—— Remoting技术之远程调用三步走
- 五种形式的网页弹出窗口代码详解
- Sun Java虚拟机畸形Gif文件处理堆溢出漏洞初步分析
- .NET Romoting 学习总结(三)—— Remoting技术之设计模式实现代码安全
- 学习java必看
- .NET Romoting 学习总结(四)—— Remoting技术细节之多通道注册