| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_FILTERS_RTC_VIDEO_DECODER_H_ | |
| 6 #define MEDIA_FILTERS_RTC_VIDEO_DECODER_H_ | |
| 7 | |
| 8 #include <deque> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/gtest_prod_util.h" | |
| 12 #include "base/time.h" | |
| 13 #include "media/base/filters.h" | |
| 14 #include "media/base/video_frame.h" | |
| 15 #include "media/filters/decoder_base.h" | |
| 16 | |
| 17 // TODO(ronghuawu) ExternalRenderer should be defined in WebRtc | |
| 18 class ExternalRenderer { | |
| 19 public: | |
| 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: | |
| 34 RTCVideoDecoder(MessageLoop* message_loop, const std::string& url); | |
| 35 virtual ~RTCVideoDecoder(); | |
| 36 | |
| 37 // Filter implementation. | |
| 38 virtual void Play(FilterCallback* callback); | |
| 39 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb); | |
| 40 virtual void Pause(FilterCallback* callback); | |
| 41 virtual void Stop(FilterCallback* callback); | |
| 42 | |
| 43 // Decoder implementation. | |
| 44 virtual void Initialize(DemuxerStream* demuxer_stream, | |
| 45 FilterCallback* filter_callback, | |
| 46 StatisticsCallback* stat_callback); | |
| 47 virtual const MediaFormat& media_format(); | |
| 48 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> video_frame); | |
| 49 virtual bool ProvidesBuffer(); | |
| 50 | |
| 51 // ExternalRenderer implementation | |
| 52 virtual int FrameSizeChange(unsigned int width, | |
| 53 unsigned int height, | |
| 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 | |
| 63 private: | |
| 64 friend class RTCVideoDecoderTest; | |
| 65 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, Initialize_Successful); | |
| 66 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoSeek); | |
| 67 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoDeliverFrame); | |
| 68 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, DoFrameSizeChange); | |
| 69 | |
| 70 enum DecoderState { | |
| 71 kUnInitialized, | |
| 72 kNormal, | |
| 73 kSeeking, | |
| 74 kPaused, | |
| 75 kStopped | |
| 76 }; | |
| 77 | |
| 78 MessageLoop* message_loop_; | |
| 79 size_t width_; | |
| 80 size_t height_; | |
| 81 std::string url_; | |
| 82 DecoderState state_; | |
| 83 MediaFormat media_format_; | |
| 84 std::deque<scoped_refptr<VideoFrame> > frame_queue_available_; | |
| 85 // Used for accessing frame queue from another thread. | |
| 86 base::Lock lock_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | |
| 89 }; | |
| 90 | |
| 91 } // namespace media | |
| 92 | |
| 93 #endif // MEDIA_FILTERS_RTC_VIDEO_DECODER_H_ | |
| OLD | NEW |