OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_RTC_VIDEO_DECODER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
6 #define MEDIA_FILTERS_RTC_VIDEO_DECODER_H_ | 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "media/base/filters.h" | 13 #include "media/base/filters.h" |
14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
15 #include "media/filters/decoder_base.h" | 15 #include "media/filters/decoder_base.h" |
16 #include "third_party/libjingle/source/talk/session/phone/mediachannel.h" | |
scherkus (not reviewing)
2011/06/27 23:06:08
woah!?
why are we now implementing cricket::Video
| |
16 | 17 |
17 // TODO(ronghuawu) ExternalRenderer should be defined in WebRtc | 18 class RTCVideoDecoder |
18 class ExternalRenderer { | 19 : public media::VideoDecoder, |
19 public: | 20 public cricket::VideoRenderer { |
20 virtual int FrameSizeChange(unsigned int width, | |
21 unsigned int height, | |
22 unsigned int number_of_streams) = 0; | |
23 virtual int DeliverFrame(unsigned char* buffer, int buffer_size) = 0; | |
24 | |
25 protected: | |
26 virtual ~ExternalRenderer() {} | |
27 }; | |
28 | |
29 namespace media { | |
30 | |
31 class RTCVideoDecoder : public VideoDecoder, | |
32 public ExternalRenderer { | |
33 public: | 21 public: |
34 RTCVideoDecoder(MessageLoop* message_loop, const std::string& url); | 22 RTCVideoDecoder(MessageLoop* message_loop, const std::string& url); |
35 virtual ~RTCVideoDecoder(); | 23 virtual ~RTCVideoDecoder(); |
36 | 24 |
37 // Filter implementation. | 25 // Filter implementation. |
38 virtual void Play(FilterCallback* callback); | 26 virtual void Play(media::FilterCallback* callback); |
39 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb); | 27 virtual void Seek(base::TimeDelta time, const media::FilterStatusCB& cb); |
40 virtual void Pause(FilterCallback* callback); | 28 virtual void Pause(media::FilterCallback* callback); |
41 virtual void Stop(FilterCallback* callback); | 29 virtual void Stop(media::FilterCallback* callback); |
42 | 30 |
43 // Decoder implementation. | 31 // Decoder implementation. |
44 virtual void Initialize(DemuxerStream* demuxer_stream, | 32 virtual void Initialize(media::DemuxerStream* demuxer_stream, |
45 FilterCallback* filter_callback, | 33 media::FilterCallback* filter_callback, |
46 StatisticsCallback* stat_callback); | 34 media::StatisticsCallback* stat_callback); |
47 virtual const MediaFormat& media_format(); | 35 virtual const media::MediaFormat& media_format(); |
48 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> video_frame); | 36 virtual void ProduceVideoFrame(scoped_refptr<media::VideoFrame> video_frame); |
49 virtual bool ProvidesBuffer(); | 37 virtual bool ProvidesBuffer(); |
50 | 38 |
51 // ExternalRenderer implementation | 39 // cricket::VideoRenderer implementation |
52 virtual int FrameSizeChange(unsigned int width, | 40 virtual bool SetSize(int width, int height, int reserved); |
53 unsigned int height, | 41 virtual bool RenderFrame(const cricket::VideoFrame *frame); |
54 unsigned int number_of_streams); | |
55 | |
56 virtual int DeliverFrame(unsigned char* buffer, | |
57 int buffer_size); | |
58 | |
59 // TODO(ronghuawu): maybe move this function to a | |
60 // base class (RawVideoDecoder) so that the camera preview may share this. | |
61 static bool IsUrlSupported(const std::string& url); | |
62 | 42 |
63 private: | 43 private: |
64 friend class RTCVideoDecoderTest; | 44 friend class RTCVideoDecoderTest; |
65 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, Initialize_Successful); | 45 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, Initialize_Successful); |
66 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoSeek); | 46 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoSeek); |
67 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoDeliverFrame); | 47 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoRenderFrame); |
68 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoFrameSizeChange); | 48 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoSetSize); |
69 | 49 |
70 enum DecoderState { | 50 enum DecoderState { |
71 kUnInitialized, | 51 kUnInitialized, |
72 kNormal, | 52 kNormal, |
73 kSeeking, | 53 kSeeking, |
74 kPaused, | 54 kPaused, |
75 kStopped | 55 kStopped |
76 }; | 56 }; |
77 | 57 |
78 MessageLoop* message_loop_; | 58 MessageLoop* message_loop_; |
79 size_t width_; | 59 size_t width_; |
80 size_t height_; | 60 size_t height_; |
81 std::string url_; | 61 std::string url_; |
82 DecoderState state_; | 62 DecoderState state_; |
83 MediaFormat media_format_; | 63 media::MediaFormat media_format_; |
84 std::deque<scoped_refptr<VideoFrame> > frame_queue_available_; | 64 std::deque<scoped_refptr<media::VideoFrame> > frame_queue_available_; |
85 // Used for accessing frame queue from another thread. | 65 // Used for accessing frame queue from another thread. |
86 base::Lock lock_; | 66 base::Lock lock_; |
87 | 67 |
88 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 68 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
89 }; | 69 }; |
90 | 70 |
91 } // namespace media | 71 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
92 | 72 |
93 #endif // MEDIA_FILTERS_RTC_VIDEO_DECODER_H_ | |
OLD | NEW |