Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: media/filters/fake_video_decoder.h

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: VideoFrameStream ready for review. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_FAKE_VIDEO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_
6 #define MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ 6 #define MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "media/base/callback_holder.h" 14 #include "media/base/callback_holder.h"
15 #include "media/base/decoder_buffer.h" 15 #include "media/base/decoder_buffer.h"
16 #include "media/base/demuxer_stream.h"
17 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
18 #include "media/base/pipeline_status.h" 17 #include "media/base/pipeline_status.h"
19 #include "media/base/video_decoder.h" 18 #include "media/base/video_decoder.h"
20 #include "media/base/video_decoder_config.h" 19 #include "media/base/video_decoder_config.h"
21 #include "media/base/video_frame.h" 20 #include "media/base/video_frame.h"
22 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
23 22
24 using base::ResetAndReturn; 23 using base::ResetAndReturn;
25 24
26 namespace base { 25 namespace base {
27 class MessageLoopProxy; 26 class MessageLoopProxy;
28 } 27 }
29 28
30 namespace media { 29 namespace media {
31 30
32 class MEDIA_EXPORT FakeVideoDecoder : public VideoDecoder { 31 class MEDIA_EXPORT FakeVideoDecoder : public VideoDecoder {
33 public: 32 public:
34 // Constructs an object with a decoding delay of |decoding_delay| frames. 33 // Constructs an object with a decoding delay of |decoding_delay| frames.
35 explicit FakeVideoDecoder(int decoding_delay); 34 explicit FakeVideoDecoder(int decoding_delay);
36 virtual ~FakeVideoDecoder(); 35 virtual ~FakeVideoDecoder();
37 36
38 // VideoDecoder implementation. 37 // VideoDecoder implementation.
39 virtual void Initialize(DemuxerStream* stream, 38 virtual void Initialize(const VideoDecoderConfig& config,
40 const PipelineStatusCB& status_cb, 39 const PipelineStatusCB& status_cb,
41 const StatisticsCB& statistics_cb) OVERRIDE; 40 const StatisticsCB& statistics_cb) OVERRIDE;
42 virtual void Read(const ReadCB& read_cb) OVERRIDE; 41 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
42 const ReadCB& read_cb) OVERRIDE;
43 virtual void Reset(const base::Closure& closure) OVERRIDE; 43 virtual void Reset(const base::Closure& closure) OVERRIDE;
44 virtual void Stop(const base::Closure& closure) OVERRIDE; 44 virtual void Stop(const base::Closure& closure) OVERRIDE;
45 45
46 // Holds the next init/read/reset/stop callback from firing. 46 // Holds the next init/read/reset/stop callback from firing.
47 void HoldNextInit(); 47 void HoldNextInit();
48 void HoldNextRead(); 48 void HoldNextRead();
49 void HoldNextReset(); 49 void HoldNextReset();
50 void HoldNextStop(); 50 void HoldNextStop();
51 51
52 // Satisfies the pending init/read/reset/stop callback, which must be ready 52 // Satisfies the pending init/read/reset/stop callback, which must be ready
53 // to fire when these methods are called. 53 // to fire when these methods are called.
54 void SatisfyInit(); 54 void SatisfyInit();
55 void SatisfyRead(); 55 void SatisfyRead();
56 void SatisfyReset(); 56 void SatisfyReset();
57 void SatisfyStop(); 57 void SatisfyStop();
58 58
59 private: 59 private:
60 enum State { 60 enum State {
61 UNINITIALIZED, 61 UNINITIALIZED,
62 NORMAL 62 NORMAL
63 }; 63 };
64 64
65 void ReadFromDemuxerStream();
66
67 // Callback for DemuxerStream::Read().
68 void BufferReady(DemuxerStream::Status status,
69 const scoped_refptr<DecoderBuffer>& buffer);
70
71 void DoReset(); 65 void DoReset();
72 void DoStop(); 66 void DoStop();
73 67
74 scoped_refptr<base::MessageLoopProxy> message_loop_; 68 scoped_refptr<base::MessageLoopProxy> message_loop_;
75 base::WeakPtrFactory<FakeVideoDecoder> weak_factory_; 69 base::WeakPtrFactory<FakeVideoDecoder> weak_factory_;
76 base::WeakPtr<FakeVideoDecoder> weak_this_; 70 base::WeakPtr<FakeVideoDecoder> weak_this_;
77 71
78 const int decoding_delay_; 72 const int decoding_delay_;
79 73
80 State state_; 74 State state_;
81 75
82 StatisticsCB statistics_cb_; 76 StatisticsCB statistics_cb_;
83 77
84 CallbackHolder<PipelineStatusCB> init_cb_; 78 CallbackHolder<PipelineStatusCB> init_cb_;
85 CallbackHolder<ReadCB> read_cb_; 79 CallbackHolder<ReadCB> read_cb_;
86 CallbackHolder<base::Closure> reset_cb_; 80 CallbackHolder<base::Closure> reset_cb_;
87 CallbackHolder<base::Closure> stop_cb_; 81 CallbackHolder<base::Closure> stop_cb_;
88 82
89 // Pointer to the demuxer stream that will feed us compressed buffers.
90 DemuxerStream* demuxer_stream_;
91
92 VideoDecoderConfig current_config_; 83 VideoDecoderConfig current_config_;
93 84
94 std::list<scoped_refptr<VideoFrame> > decoded_frames_; 85 std::list<scoped_refptr<VideoFrame> > decoded_frames_;
95 86
96 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder); 87 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder);
97 }; 88 };
98 89
99 } // namespace media 90 } // namespace media
100 91
101 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ 92 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698