OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_ | |
6 #define CHROME_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_ | |
7 | |
8 #include "base/time.h" | |
9 #include "media/base/pts_heap.h" | |
10 #include "media/base/video_frame.h" | |
11 #include "media/filters/decoder_base.h" | |
12 #include "media/video/video_decode_engine.h" | |
13 #include "media/video/video_decode_context.h" | |
14 | |
15 struct AVRational; | |
16 | |
17 namespace ggl { | |
18 class Context; | |
19 } // namespace ggl | |
20 | |
21 class IpcVideoDecoder : public media::VideoDecoder, | |
22 public media::VideoDecodeEngine::EventHandler { | |
23 public: | |
24 IpcVideoDecoder(MessageLoop* message_loop, ggl::Context* ggl_context); | |
25 virtual ~IpcVideoDecoder(); | |
26 | |
27 // media::Filter implementation. | |
28 virtual void Stop(media::FilterCallback* callback); | |
29 virtual void Seek(base::TimeDelta time, media::FilterCallback* callback); | |
30 virtual void Pause(media::FilterCallback* callback); | |
31 virtual void Flush(media::FilterCallback* callback); | |
32 | |
33 // media::VideoDecoder implementation. | |
34 virtual void Initialize(media::DemuxerStream* demuxer_stream, | |
35 media::FilterCallback* callback, | |
36 media::StatisticsCallback* statsCallback); | |
37 virtual const media::MediaFormat& media_format(); | |
38 virtual void ProduceVideoFrame(scoped_refptr<media::VideoFrame> video_frame); | |
39 | |
40 // TODO(hclam): Remove this method. | |
41 virtual bool ProvidesBuffer(); | |
42 | |
43 // media::VideoDecodeEngine::EventHandler implementation. | |
44 virtual void OnInitializeComplete(const media::VideoCodecInfo& info); | |
45 virtual void OnUninitializeComplete(); | |
46 virtual void OnFlushComplete(); | |
47 virtual void OnSeekComplete(); | |
48 virtual void OnError(); | |
49 | |
50 // TODO(hclam): Remove this method. | |
51 virtual void OnFormatChange(media::VideoStreamInfo stream_info) {} | |
52 virtual void ProduceVideoSample(scoped_refptr<media::Buffer> buffer); | |
53 virtual void ConsumeVideoFrame(scoped_refptr<media::VideoFrame> frame, | |
54 const media::PipelineStatistics& statistics); | |
55 | |
56 private: | |
57 void OnReadComplete(media::Buffer* buffer); | |
58 void OnDestroyComplete(); | |
59 | |
60 media::MediaFormat media_format_; | |
61 | |
62 scoped_ptr<media::FilterCallback> flush_callback_; | |
63 scoped_ptr<media::FilterCallback> seek_callback_; | |
64 scoped_ptr<media::FilterCallback> initialize_callback_; | |
65 scoped_ptr<media::FilterCallback> stop_callback_; | |
66 scoped_ptr<media::StatisticsCallback> statistics_callback_; | |
67 | |
68 // Pointer to the demuxer stream that will feed us compressed buffers. | |
69 scoped_refptr<media::DemuxerStream> demuxer_stream_; | |
70 | |
71 // This is the message loop that we should assign to VideoDecodeContext. | |
72 MessageLoop* decode_context_message_loop_; | |
73 | |
74 // A context for allocating textures and issuing GLES2 commands. | |
75 // TODO(hclam): A ggl::Context lives on the Render Thread while this object | |
76 // lives on the Video Decoder Thread, we need to take care of context lost | |
77 // and destruction of the context. | |
78 ggl::Context* ggl_context_; | |
79 | |
80 // This VideoDecodeEngine translate our requests to IPC commands to the | |
81 // GPU process. | |
82 // VideoDecodeEngine should run on IO Thread instead of Render Thread to | |
83 // avoid dead lock during tear down of the media pipeline. | |
84 scoped_ptr<media::VideoDecodeEngine> decode_engine_; | |
85 | |
86 // Decoding context to be used by VideoDecodeEngine. | |
87 scoped_ptr<media::VideoDecodeContext> decode_context_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(IpcVideoDecoder); | |
90 }; | |
91 | |
92 #endif // CHROME_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_ | |
OLD | NEW |