-
Notifications
You must be signed in to change notification settings - Fork 2
/
TypeHandler.h
86 lines (73 loc) · 2.06 KB
/
TypeHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// TypeHandler.h: interface for type-specific handlers.
//
// Copyright (c) GDCL 2004-6. All Rights Reserved.
// You are free to re-use this as the basis for your own filter development,
// provided you retain this copyright notice in the source.
// http://www.gdcl.co.uk
//////////////////////////////////////////////////////////////////////
#pragma once
class Atom;
class MovieWriter;
// directshow subtypes
class Descriptor
{
public:
enum TagType
{
Invalid = 0,
ES_Desc = 3,
Decoder_Config = 4,
Decoder_Specific_Info = 5,
SL_Config = 6,
ES_ID_Inc = 0x0e,
ES_ID_Ref = 0x0f,
MP4_IOD = 0x10,
MP4_OD = 0x11,
// Command tags
ObjDescrUpdate = 1,
};
Descriptor(TagType type);
void Append(const BYTE* pBuffer, long cBytes);
void Append(Descriptor* pdesc);
long Length();
void Write(BYTE* pBuffer);
HRESULT Write(Atom* patm);
private:
void Reserve(long cBytes);
private:
TagType m_type;
long m_cBytes;
long m_cValid;
smart_array<BYTE> m_pBuffer;
};
class Atom;
// abstract interface and factory
class TypeHandler
{
public:
virtual ~TypeHandler() {}
virtual DWORD Handler() = 0;
virtual void WriteTREF(Atom* patm) = 0;
virtual bool IsVideo() = 0;
virtual bool IsAudio() = 0;
virtual void WriteDescriptor(Atom* patm, int id, int dataref, long scale) = 0;
virtual long SampleRate() = 0;
virtual long Scale() = 0;
virtual long Width() = 0;
virtual long Height() = 0;
virtual bool CanTruncate() { return false; }
virtual bool Truncate(IMediaSample* pSample, REFERENCE_TIME tNewStart)
{
UNREFERENCED_PARAMETER(pSample);
UNREFERENCED_PARAMETER(tNewStart);
return false;
}
virtual LONGLONG FrameDuration()
{
// default answer
return UNITS / SampleRate();
}
virtual HRESULT WriteData(Atom* patm, const BYTE* pData, int cBytes, int* pcActual);
static bool CanSupport(const CMediaType* pmt);
static TypeHandler* Make(const CMediaType* pmt);
};