OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_FILTERS_VIDEO_DECODER_IMPL_H_ | 5 #ifndef MEDIA_FILTERS_VIDEO_DECODER_IMPL_H_ |
6 #define MEDIA_FILTERS_VIDEO_DECODER_IMPL_H_ | 6 #define MEDIA_FILTERS_VIDEO_DECODER_IMPL_H_ |
7 | 7 |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "media/base/pts_heap.h" | 9 #include "media/base/pts_heap.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
11 #include "media/filters/decoder_base.h" | 11 #include "media/filters/decoder_base.h" |
12 #include "testing/gtest/include/gtest/gtest_prod.h" | 12 #include "testing/gtest/include/gtest/gtest_prod.h" |
13 | 13 |
14 // FFmpeg types. | 14 // FFmpeg types. |
15 struct AVFrame; | |
16 struct AVRational; | 15 struct AVRational; |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 | 18 |
20 class VideoDecodeEngine; | 19 class VideoDecodeEngine; |
21 | 20 |
22 class VideoDecoderImpl : public DecoderBase<VideoDecoder, VideoFrame> { | 21 class VideoDecoderImpl : public DecoderBase<VideoDecoder, VideoFrame> { |
23 protected: | 22 protected: |
24 VideoDecoderImpl(VideoDecodeEngine* engine); | 23 VideoDecoderImpl(VideoDecodeEngine* engine); |
25 | 24 |
(...skipping 28 matching lines...) Expand all Loading... |
54 kFlushCodec, | 53 kFlushCodec, |
55 kDecodeFinished, | 54 kDecodeFinished, |
56 }; | 55 }; |
57 | 56 |
58 // Implement DecoderBase template methods. | 57 // Implement DecoderBase template methods. |
59 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, | 58 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, |
60 Task* done_cb); | 59 Task* done_cb); |
61 virtual void DoSeek(base::TimeDelta time, Task* done_cb); | 60 virtual void DoSeek(base::TimeDelta time, Task* done_cb); |
62 virtual void DoDecode(Buffer* buffer, Task* done_cb); | 61 virtual void DoDecode(Buffer* buffer, Task* done_cb); |
63 | 62 |
64 virtual bool EnqueueVideoFrame(VideoFrame::Format surface_format, | 63 virtual void EnqueueVideoFrame(const scoped_refptr<VideoFrame>& video_frame); |
65 const TimeTuple& time, | |
66 const AVFrame* frame); | |
67 | 64 |
68 // Create an empty video frame and queue it. | 65 // Create an empty video frame and queue it. |
69 virtual void EnqueueEmptyFrame(); | 66 virtual void EnqueueEmptyFrame(); |
70 | 67 |
71 virtual void CopyPlane(size_t plane, const VideoFrame& video_frame, | |
72 const AVFrame* frame); | |
73 | |
74 // Methods that pickup after the decode engine has finished its action. | 68 // Methods that pickup after the decode engine has finished its action. |
75 virtual void OnInitializeComplete(bool* success /* Not owned */, | 69 virtual void OnInitializeComplete(bool* success /* Not owned */, |
76 Task* done_cb); | 70 Task* done_cb); |
77 virtual void OnDecodeComplete(AVFrame* yuv_frame, bool* got_frame, | 71 virtual void OnDecodeComplete(scoped_refptr<VideoFrame>* video_frame, |
78 Task* done_cb); | 72 bool* got_frame, Task* done_cb); |
79 | 73 |
80 // Attempt to get the PTS and Duration for this frame by examining the time | 74 // Attempt to get the PTS and Duration for this frame by examining the time |
81 // info provided via packet stream (stored in |pts_heap|), or the info | 75 // info provided via packet stream (stored in |pts_heap|), or the info |
82 // writen into the AVFrame itself. If no data is available in either, then | 76 // writen into the AVFrame itself. If no data is available in either, then |
83 // attempt to generate a best guess of the pts based on the last known pts. | 77 // attempt to generate a best guess of the pts based on the last known pts. |
84 // | 78 // |
85 // Data inside the AVFrame (if provided) is trusted the most, followed | 79 // Data inside the AVFrame (if provided) is trusted the most, followed |
86 // by data from the packet stream. Estimation based on the |last_pts| is | 80 // by data from the packet stream. Estimation based on the |last_pts| is |
87 // reserved as a last-ditch effort. | 81 // reserved as a last-ditch effort. |
88 virtual TimeTuple FindPtsAndDuration(const AVRational& time_base, | 82 virtual TimeTuple FindPtsAndDuration(const AVRational& time_base, |
89 const PtsHeap& pts_heap, | 83 const PtsHeap& pts_heap, |
90 const TimeTuple& last_pts, | 84 const TimeTuple& last_pts, |
91 const AVFrame* frame); | 85 const VideoFrame* frame); |
92 | 86 |
93 // Signals the pipeline that a decode error occurs, and moves the decoder | 87 // Signals the pipeline that a decode error occurs, and moves the decoder |
94 // into the kDecodeFinished state. | 88 // into the kDecodeFinished state. |
95 virtual void SignalPipelineError(); | 89 virtual void SignalPipelineError(); |
96 | 90 |
97 // Injection point for unittest to provide a mock engine. Takes ownership of | 91 // Injection point for unittest to provide a mock engine. Takes ownership of |
98 // the provided engine. | 92 // the provided engine. |
99 virtual void SetVideoDecodeEngineForTest(VideoDecodeEngine* engine); | 93 virtual void SetVideoDecodeEngineForTest(VideoDecodeEngine* engine); |
100 | 94 |
101 size_t width_; | 95 size_t width_; |
102 size_t height_; | 96 size_t height_; |
103 | 97 |
104 PtsHeap pts_heap_; // Heap of presentation timestamps. | 98 PtsHeap pts_heap_; // Heap of presentation timestamps. |
105 TimeTuple last_pts_; | 99 TimeTuple last_pts_; |
106 scoped_ptr<AVRational> time_base_; // Pointer to avoid needing full type. | 100 scoped_ptr<AVRational> time_base_; // Pointer to avoid needing full type. |
107 DecoderState state_; | 101 DecoderState state_; |
108 scoped_ptr<VideoDecodeEngine> decode_engine_; | 102 scoped_ptr<VideoDecodeEngine> decode_engine_; |
109 | 103 |
110 DISALLOW_COPY_AND_ASSIGN(VideoDecoderImpl); | 104 DISALLOW_COPY_AND_ASSIGN(VideoDecoderImpl); |
111 }; | 105 }; |
112 | 106 |
113 } // namespace media | 107 } // namespace media |
114 | 108 |
115 #endif // MEDIA_FILTERS_VIDEO_DECODER_IMPL_H_ | 109 #endif // MEDIA_FILTERS_VIDEO_DECODER_IMPL_H_ |
OLD | NEW |