| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 "chrome/renderer/gpu_video_service_host.h" | |
| 10 #include "media/base/pts_heap.h" | |
| 11 #include "media/base/video_frame.h" | |
| 12 #include "media/filters/decoder_base.h" | |
| 13 | |
| 14 struct AVRational; | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 class VideoDecodeEngine; | |
| 19 | |
| 20 class IpcVideoDecoder : public VideoDecoder, | |
| 21 public GpuVideoDecoderHost::EventHandler { | |
| 22 public: | |
| 23 explicit IpcVideoDecoder(MessageLoop* message_loop); | |
| 24 virtual ~IpcVideoDecoder(); | |
| 25 | |
| 26 static FilterFactory* CreateFactory(MessageLoop* message_loop); | |
| 27 static bool IsMediaFormatSupported(const MediaFormat& media_format); | |
| 28 | |
| 29 // MediaFilter implementation. | |
| 30 virtual void Stop(FilterCallback* callback); | |
| 31 virtual void Seek(base::TimeDelta time, FilterCallback* callback); | |
| 32 virtual void Pause(FilterCallback* callback); | |
| 33 virtual void Flush(FilterCallback* callback); | |
| 34 | |
| 35 // Decoder implementation. | |
| 36 virtual void Initialize(DemuxerStream* demuxer_stream, | |
| 37 FilterCallback* callback); | |
| 38 virtual const MediaFormat& media_format() { return media_format_; } | |
| 39 virtual void FillThisBuffer(scoped_refptr<VideoFrame> video_frame); | |
| 40 | |
| 41 // GpuVideoDecoderHost::EventHandler. | |
| 42 virtual void OnInitializeDone(bool success, | |
| 43 const GpuVideoDecoderInitDoneParam& param); | |
| 44 virtual void OnUninitializeDone(); | |
| 45 virtual void OnFlushDone(); | |
| 46 virtual void OnEmptyBufferDone(scoped_refptr<Buffer> buffer); | |
| 47 virtual void OnFillBufferDone(scoped_refptr<VideoFrame> frame); | |
| 48 virtual void OnDeviceError(); | |
| 49 | |
| 50 virtual bool ProvidesBuffer(); | |
| 51 | |
| 52 private: | |
| 53 void OnSeekComplete(FilterCallback* callback); | |
| 54 void OnReadComplete(Buffer* buffer); | |
| 55 void ReadCompleteTask(scoped_refptr<Buffer> buffer); | |
| 56 | |
| 57 private: | |
| 58 friend class FilterFactoryImpl2<IpcVideoDecoder, | |
| 59 VideoDecodeEngine*, | |
| 60 MessageLoop*>; | |
| 61 | |
| 62 private: | |
| 63 int32 width_; | |
| 64 int32 height_; | |
| 65 MediaFormat media_format_; | |
| 66 | |
| 67 scoped_ptr<FilterCallback> flush_callback_; | |
| 68 scoped_ptr<FilterCallback> initialize_callback_; | |
| 69 scoped_ptr<FilterCallback> stop_callback_; | |
| 70 | |
| 71 enum DecoderState { | |
| 72 kUnInitialized, | |
| 73 kPlaying, | |
| 74 kFlushing, | |
| 75 kPausing, | |
| 76 kFlushCodec, | |
| 77 kEnded, | |
| 78 kStopped, | |
| 79 }; | |
| 80 DecoderState state_; | |
| 81 | |
| 82 // Tracks the number of asynchronous reads issued to |demuxer_stream_|. | |
| 83 // Using size_t since it is always compared against deque::size(). | |
| 84 size_t pending_reads_; | |
| 85 // Tracks the number of asynchronous reads issued from renderer. | |
| 86 size_t pending_requests_; | |
| 87 | |
| 88 // Pointer to the demuxer stream that will feed us compressed buffers. | |
| 89 scoped_refptr<DemuxerStream> demuxer_stream_; | |
| 90 | |
| 91 MessageLoop* renderer_thread_message_loop_; | |
| 92 scoped_refptr<GpuVideoDecoderHost> gpu_video_decoder_host_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(IpcVideoDecoder); | |
| 95 }; | |
| 96 | |
| 97 } // namespace media | |
| 98 | |
| 99 #endif // CHROME_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_ | |
| 100 | |
| OLD | NEW |