2 * GStreamer splitter + decoder, adapted from parser.c
4 * Copyright 2010 Maarten Lankhorst for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __GST_PRIVATE_INCLUDED__
22 #define __GST_PRIVATE_INCLUDED__
32 #define NONAMELESSSTRUCT
33 #define NONAMELESSUNION
37 #include "wine/debug.h"
38 #include "wine/strmbase.h"
42 bool array_reserve(void **elements
, size_t *capacity
, size_t count
, size_t size
) DECLSPEC_HIDDEN
;
44 static inline const char *debugstr_time(REFERENCE_TIME time
)
46 ULONGLONG abstime
= time
>= 0 ? time
: -time
;
47 unsigned int i
= 0, j
= 0;
48 char buffer
[23], rev
[23];
50 while (abstime
|| i
<= 8)
52 buffer
[i
++] = '0' + (abstime
% 10);
54 if (i
== 7) buffer
[i
++] = '.';
56 if (time
< 0) buffer
[i
++] = '-';
58 while (i
--) rev
[j
++] = buffer
[i
];
59 while (rev
[j
-1] == '0' && rev
[j
-2] != '.') --j
;
62 return wine_dbg_sprintf("%s", rev
);
65 #define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000)
67 struct wg_parser
*wg_parser_create(enum wg_parser_type type
, bool unlimited_buffering
) DECLSPEC_HIDDEN
;
68 void wg_parser_destroy(struct wg_parser
*parser
) DECLSPEC_HIDDEN
;
70 HRESULT
wg_parser_connect(struct wg_parser
*parser
, uint64_t file_size
) DECLSPEC_HIDDEN
;
71 void wg_parser_disconnect(struct wg_parser
*parser
) DECLSPEC_HIDDEN
;
73 void wg_parser_begin_flush(struct wg_parser
*parser
) DECLSPEC_HIDDEN
;
74 void wg_parser_end_flush(struct wg_parser
*parser
) DECLSPEC_HIDDEN
;
76 bool wg_parser_get_next_read_offset(struct wg_parser
*parser
, uint64_t *offset
, uint32_t *size
) DECLSPEC_HIDDEN
;
77 void wg_parser_push_data(struct wg_parser
*parser
, const void *data
, uint32_t size
) DECLSPEC_HIDDEN
;
79 uint32_t wg_parser_get_stream_count(struct wg_parser
*parser
) DECLSPEC_HIDDEN
;
80 struct wg_parser_stream
*wg_parser_get_stream(struct wg_parser
*parser
, uint32_t index
) DECLSPEC_HIDDEN
;
82 void wg_parser_stream_get_preferred_format(struct wg_parser_stream
*stream
, struct wg_format
*format
) DECLSPEC_HIDDEN
;
83 void wg_parser_stream_enable(struct wg_parser_stream
*stream
, const struct wg_format
*format
) DECLSPEC_HIDDEN
;
84 void wg_parser_stream_disable(struct wg_parser_stream
*stream
) DECLSPEC_HIDDEN
;
86 bool wg_parser_stream_get_event(struct wg_parser_stream
*stream
, struct wg_parser_event
*event
) DECLSPEC_HIDDEN
;
87 bool wg_parser_stream_copy_buffer(struct wg_parser_stream
*stream
,
88 void *data
, uint32_t offset
, uint32_t size
) DECLSPEC_HIDDEN
;
89 void wg_parser_stream_release_buffer(struct wg_parser_stream
*stream
) DECLSPEC_HIDDEN
;
90 void wg_parser_stream_notify_qos(struct wg_parser_stream
*stream
,
91 bool underflow
, double proportion
, int64_t diff
, uint64_t timestamp
) DECLSPEC_HIDDEN
;
93 /* Returns the duration in 100-nanosecond units. */
94 uint64_t wg_parser_stream_get_duration(struct wg_parser_stream
*stream
) DECLSPEC_HIDDEN
;
95 /* start_pos and stop_pos are in 100-nanosecond units. */
96 void wg_parser_stream_seek(struct wg_parser_stream
*stream
, double rate
,
97 uint64_t start_pos
, uint64_t stop_pos
, DWORD start_flags
, DWORD stop_flags
) DECLSPEC_HIDDEN
;
99 unsigned int wg_format_get_max_size(const struct wg_format
*format
);
101 HRESULT
avi_splitter_create(IUnknown
*outer
, IUnknown
**out
) DECLSPEC_HIDDEN
;
102 HRESULT
decodebin_parser_create(IUnknown
*outer
, IUnknown
**out
) DECLSPEC_HIDDEN
;
103 HRESULT
mpeg_splitter_create(IUnknown
*outer
, IUnknown
**out
) DECLSPEC_HIDDEN
;
104 HRESULT
wave_parser_create(IUnknown
*outer
, IUnknown
**out
) DECLSPEC_HIDDEN
;
105 HRESULT
wma_decoder_create(IUnknown
*outer
, IUnknown
**out
) DECLSPEC_HIDDEN
;
107 bool amt_from_wg_format(AM_MEDIA_TYPE
*mt
, const struct wg_format
*format
, bool wm
);
108 bool amt_to_wg_format(const AM_MEDIA_TYPE
*mt
, struct wg_format
*format
);
110 BOOL
init_gstreamer(void) DECLSPEC_HIDDEN
;
112 extern HRESULT
mfplat_get_class_object(REFCLSID rclsid
, REFIID riid
, void **obj
) DECLSPEC_HIDDEN
;
113 extern HRESULT
mfplat_DllRegisterServer(void) DECLSPEC_HIDDEN
;
115 IMFMediaType
*mf_media_type_from_wg_format(const struct wg_format
*format
) DECLSPEC_HIDDEN
;
116 void mf_media_type_to_wg_format(IMFMediaType
*type
, struct wg_format
*format
) DECLSPEC_HIDDEN
;
118 HRESULT
winegstreamer_stream_handler_create(REFIID riid
, void **obj
) DECLSPEC_HIDDEN
;
120 HRESULT
audio_converter_create(REFIID riid
, void **ret
) DECLSPEC_HIDDEN
;
124 struct wm_reader
*reader
;
125 struct wg_parser_stream
*wg_stream
;
126 struct wg_format format
;
127 WMT_STREAM_SELECTION selection
;
130 bool allocate_output
;
131 bool allocate_stream
;
132 /* Note that we only pretend to read compressed samples, and instead output
133 * uncompressed samples regardless of whether we are configured to read
134 * compressed samples. Rather, the behaviour of the reader objects differs
135 * in nontrivial ways depending on this field. */
136 bool read_compressed
;
141 IWMHeaderInfo3 IWMHeaderInfo3_iface
;
142 IWMLanguageList IWMLanguageList_iface
;
143 IWMPacketSize2 IWMPacketSize2_iface
;
144 IWMProfile3 IWMProfile3_iface
;
145 IWMReaderPlaylistBurn IWMReaderPlaylistBurn_iface
;
146 IWMReaderTimecode IWMReaderTimecode_iface
;
152 IStream
*source_stream
;
155 bool read_thread_shutdown
;
156 struct wg_parser
*wg_parser
;
158 struct wm_stream
*streams
;
161 IWMReaderCallbackAdvanced
*callback_advanced
;
163 const struct wm_reader_ops
*ops
;
168 void *(*query_interface
)(struct wm_reader
*reader
, REFIID iid
);
169 void (*destroy
)(struct wm_reader
*reader
);
172 void wm_reader_cleanup(struct wm_reader
*reader
);
173 HRESULT
wm_reader_close(struct wm_reader
*reader
);
174 HRESULT
wm_reader_get_max_stream_size(struct wm_reader
*reader
, WORD stream_number
, DWORD
*size
);
175 HRESULT
wm_reader_get_output_format(struct wm_reader
*reader
, DWORD output
,
176 DWORD index
, IWMOutputMediaProps
**props
);
177 HRESULT
wm_reader_get_output_format_count(struct wm_reader
*reader
, DWORD output
, DWORD
*count
);
178 HRESULT
wm_reader_get_output_props(struct wm_reader
*reader
, DWORD output
,
179 IWMOutputMediaProps
**props
);
180 struct wm_stream
*wm_reader_get_stream_by_stream_number(struct wm_reader
*reader
,
182 HRESULT
wm_reader_get_stream_sample(struct wm_stream
*stream
,
183 INSSBuffer
**sample
, QWORD
*pts
, QWORD
*duration
, DWORD
*flags
);
184 HRESULT
wm_reader_get_stream_selection(struct wm_reader
*reader
,
185 WORD stream_number
, WMT_STREAM_SELECTION
*selection
);
186 void wm_reader_init(struct wm_reader
*reader
, const struct wm_reader_ops
*ops
);
187 HRESULT
wm_reader_open_file(struct wm_reader
*reader
, const WCHAR
*filename
);
188 HRESULT
wm_reader_open_stream(struct wm_reader
*reader
, IStream
*stream
);
189 void wm_reader_seek(struct wm_reader
*reader
, QWORD start
, LONGLONG duration
);
190 HRESULT
wm_reader_set_allocate_for_output(struct wm_reader
*reader
, DWORD output
, BOOL allocate
);
191 HRESULT
wm_reader_set_allocate_for_stream(struct wm_reader
*reader
, WORD stream_number
, BOOL allocate
);
192 HRESULT
wm_reader_set_output_props(struct wm_reader
*reader
, DWORD output
,
193 IWMOutputMediaProps
*props
);
194 HRESULT
wm_reader_set_read_compressed(struct wm_reader
*reader
,
195 WORD stream_number
, BOOL compressed
);
196 HRESULT
wm_reader_set_streams_selected(struct wm_reader
*reader
, WORD count
,
197 const WORD
*stream_numbers
, const WMT_STREAM_SELECTION
*selections
);
199 #endif /* __GST_PRIVATE_INCLUDED__ */