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 "content/renderer/media/webrtc_external_renderer.h" | |
13 #include "media/base/filters.h" | 14 #include "media/base/filters.h" |
14 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
15 #include "media/filters/decoder_base.h" | 16 #include "media/filters/decoder_base.h" |
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 ExternalRenderer { |
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 // ExternalRenderer implementation |
52 virtual int FrameSizeChange(unsigned int width, | 40 virtual int FrameSizeChange(unsigned int width, |
scherkus (not reviewing)
2011/06/29 00:39:28
instead of "unsigned int" use either "int" or if y
Ronghua
2011/06/29 20:36:39
The ExternalRenderer interface is defined in WebRT
| |
53 unsigned int height, | 41 unsigned int height, |
54 unsigned int number_of_streams); | 42 unsigned int number_of_streams); |
55 | 43 |
56 virtual int DeliverFrame(unsigned char* buffer, | 44 virtual int DeliverFrame(unsigned char* buffer, |
scherkus (not reviewing)
2011/06/29 00:39:28
"unsigned char" -> uint8
Ronghua
2011/06/29 20:36:39
The ExternalRenderer interface is defined in WebRT
| |
57 int buffer_size); | 45 int buffer_size); |
58 | 46 |
59 // TODO(ronghuawu): maybe move this function to a | 47 // TODO(ronghuawu): maybe move this function to a |
60 // base class (RawVideoDecoder) so that the camera preview may share this. | 48 // base class (RawVideoDecoder) so that the camera preview may share this. |
61 static bool IsUrlSupported(const std::string& url); | 49 static bool IsUrlSupported(const std::string& url); |
scherkus (not reviewing)
2011/06/29 00:39:28
this is no longer defined in the .cc
Ronghua
2011/06/29 20:36:39
Done.
| |
62 | 50 |
63 private: | 51 private: |
64 friend class RTCVideoDecoderTest; | 52 friend class RTCVideoDecoderTest; |
65 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, Initialize_Successful); | 53 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, Initialize_Successful); |
66 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoSeek); | 54 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoSeek); |
67 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoDeliverFrame); | 55 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoDeliverFrame); |
68 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoFrameSizeChange); | 56 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoFrameSizeChange); |
69 | 57 |
70 enum DecoderState { | 58 enum DecoderState { |
71 kUnInitialized, | 59 kUnInitialized, |
72 kNormal, | 60 kNormal, |
73 kSeeking, | 61 kSeeking, |
74 kPaused, | 62 kPaused, |
75 kStopped | 63 kStopped |
76 }; | 64 }; |
77 | 65 |
78 MessageLoop* message_loop_; | 66 MessageLoop* message_loop_; |
79 size_t width_; | 67 size_t width_; |
80 size_t height_; | 68 size_t height_; |
81 std::string url_; | 69 std::string url_; |
82 DecoderState state_; | 70 DecoderState state_; |
83 MediaFormat media_format_; | 71 media::MediaFormat media_format_; |
84 std::deque<scoped_refptr<VideoFrame> > frame_queue_available_; | 72 std::deque<scoped_refptr<media::VideoFrame> > frame_queue_available_; |
85 // Used for accessing frame queue from another thread. | 73 // Used for accessing frame queue from another thread. |
86 base::Lock lock_; | 74 base::Lock lock_; |
87 | 75 |
88 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 76 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
89 }; | 77 }; |
90 | 78 |
91 } // namespace media | 79 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
92 | 80 |
scherkus (not reviewing)
2011/06/29 00:39:28
nit: could you get rid of blank line here
Ronghua
2011/06/29 20:36:39
Done.
| |
93 #endif // MEDIA_FILTERS_RTC_VIDEO_DECODER_H_ | |
OLD | NEW |