Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SubtitleSource.h « SubtitleSource « source « filters « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4667019164bf8a69125f5b4157b9e56cb53d7222 (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * (C) 2003-2006 Gabest
 * (C) 2006-2012 see Authors.txt
 *
 * This file is part of MPC-HC.
 *
 * MPC-HC is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * MPC-HC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#pragma once

#include <atlbase.h>
#include "../../../Subtitles/RTS.h"

#define SubtitleSourceName   L"MPC Subtitle Source"

class CSubtitleSource
    : public CSource
    , public IFileSourceFilter
    , public IAMFilterMiscFlags
{
protected:
    CStringW m_fn;

public:
    CSubtitleSource(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid);
    virtual ~CSubtitleSource();

    DECLARE_IUNKNOWN;
    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);

    // IFileSourceFilter
    STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
    STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);

    // IAMFilterMiscFlags
    STDMETHODIMP_(ULONG) GetMiscFlags();

    virtual HRESULT GetMediaType(CMediaType* pmt) = 0;

    // CBaseFilter
    STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
};

class CSubtitleStream
    : public CSourceStream
    , public CSourceSeeking
{
    CCritSec m_cSharedState;

    int m_nPosition;

    BOOL m_bDiscontinuity, m_bFlushing;

    HRESULT OnThreadStartPlay();
    HRESULT OnThreadCreate();

    void UpdateFromSeek();
    STDMETHODIMP SetRate(double dRate);

    HRESULT ChangeStart();
    HRESULT ChangeStop();
    HRESULT ChangeRate() { return S_OK; }

protected:
    CRenderedTextSubtitle m_rts;

public:
    CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr);
    virtual ~CSubtitleStream();

    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);

    HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
    HRESULT FillBuffer(IMediaSample* pSample);
    HRESULT GetMediaType(CMediaType* pmt);
    HRESULT CheckMediaType(const CMediaType* pmt);

    STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};

class __declspec(uuid("E44CA3B5-A0FF-41A0-AF16-42429B1095EA"))
    CSubtitleSourceASCII : public CSubtitleSource
{
public:
    CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};

class __declspec(uuid("87864E0F-7073-4E39-B802-143DE0ED4964"))
    CSubtitleSourceUTF8 : public CSubtitleSource
{
public:
    CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};

class __declspec(uuid("18316B1A-5877-4CC4-85FD-EDE65CD489EC"))
    CSubtitleSourceSSA : public CSubtitleSource
{
public:
    CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};

class __declspec(uuid("416782BC-1D87-48C0-8F65-F113A5CB8E15"))
    CSubtitleSourceASS : public CSubtitleSource
{
public:
    CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};

class __declspec(uuid("D7215AFC-DFE6-483B-9AF3-6BBECFF14CF4"))
    CSubtitleSourceUSF : public CSubtitleSource
{
public:
    CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};

class __declspec(uuid("932E75D4-BBD4-4A0F-9071-6728FBDC4C98"))
    CSubtitleSourcePreview : public CSubtitleSource
{
public:
    CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};

class __declspec(uuid("CF0D7280-527D-415E-BA02-56017484D73E"))
    CSubtitleSourceARGB : public CSubtitleSource
{
public:
    CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr);

    HRESULT GetMediaType(CMediaType* pmt);
};