Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_CAST_VIDEO_RECEIVER_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_CAST_VIDEO_RECEIVER_VIDEO_DECODER_H_ |
| 6 #define MEDIA_CAST_VIDEO_RECEIVER_VIDEO_DECODER_H_ | 6 #define MEDIA_CAST_VIDEO_RECEIVER_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/threading/non_thread_safe.h" | 11 #include "media/base/video_frame.h" |
| 10 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
| 11 #include "media/cast/cast_receiver.h" | 13 #include "media/cast/transport/cast_transport_config.h" |
| 12 | 14 |
| 13 namespace media { | 15 namespace media { |
| 14 namespace cast { | 16 namespace cast { |
| 15 | 17 |
| 16 class Vp8Decoder; | 18 class CastEnvironment; |
| 17 class VideoFrame; | |
| 18 | 19 |
| 19 // This class is not thread safe; it's only called from the cast video decoder | 20 class VideoDecoder { |
| 20 // thread. | |
| 21 class VideoDecoder : public base::NonThreadSafe { | |
| 22 public: | 21 public: |
| 23 VideoDecoder(const VideoReceiverConfig& video_config, | 22 // Callback passed to DecodeFrame, to deliver a decoded video frame from the |
| 24 scoped_refptr<CastEnvironment> cast_environment); | 23 // decoder. |frame| can be NULL when errors occur. |is_continuous| is |
| 24 // normally true, but will be false if the decoder has detected a frame skip | |
| 25 // since the last decode operation; and the client might choose to take steps | |
| 26 // to smooth/interpolate video discontinuities in this case. | |
| 27 typedef base::Callback<void(const scoped_refptr<VideoFrame>& frame, | |
| 28 bool is_continuous)> DecodeFrameCallback; | |
| 29 | |
| 30 VideoDecoder(const scoped_refptr<CastEnvironment>& cast_environment, | |
| 31 const VideoReceiverConfig& video_config); | |
| 25 virtual ~VideoDecoder(); | 32 virtual ~VideoDecoder(); |
| 26 | 33 |
| 27 // Decode a video frame. Decoded (raw) frame will be returned via the | 34 // Returns STATUS_VIDEO_INITIALIZED if the decoder was successfully |
| 28 // provided callback | 35 // constructed from the given VideoReceiverConfig. If this method returns any |
| 29 bool DecodeVideoFrame(const transport::EncodedVideoFrame* encoded_frame, | 36 // other value, calls to DecodeFrame() will not succeed. |
| 30 const base::TimeTicks render_time, | 37 CastInitializationStatus InitializationResult() const; |
| 31 const VideoFrameDecodedCallback& frame_decoded_cb); | 38 |
| 39 // Decode the payload in |encoded_frame| asynchronously. |callback| will be | |
| 40 // invoked on the CastEnvironment::MAIN thread with the result. | |
| 41 // | |
| 42 // In the normal case, |encoded_frame->frame_id| will be | |
| 43 // monotonically-increasing by 1 for each successive call to this method. | |
|
hubbe
2014/04/07 18:40:17
This is not really how cast works/should work, per
miu
2014/04/08 00:59:41
As discussed, it is how it works; but probably not
| |
| 44 // When it is not, the decoder will assume one or more frames have been | |
| 45 // dropped (e.g., due to packet loss), and will perform recovery actions. | |
| 46 void DecodeFrame(scoped_ptr<transport::EncodedVideoFrame> encoded_frame, | |
| 47 const DecodeFrameCallback& callback); | |
| 32 | 48 |
| 33 private: | 49 private: |
| 34 transport::VideoCodec codec_; | 50 class ImplBase; |
| 35 scoped_ptr<Vp8Decoder> vp8_decoder_; | 51 class Vp8Impl; |
| 52 | |
| 53 const scoped_refptr<CastEnvironment> cast_environment_; | |
| 54 scoped_refptr<ImplBase> impl_; | |
| 36 | 55 |
| 37 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 56 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
| 38 }; | 57 }; |
| 39 | 58 |
| 40 } // namespace cast | 59 } // namespace cast |
| 41 } // namespace media | 60 } // namespace media |
| 42 | 61 |
| 43 #endif // MEDIA_CAST_VIDEO_RECEIVER_VIDEO_DECODER_H_ | 62 #endif // MEDIA_CAST_VIDEO_RECEIVER_VIDEO_DECODER_H_ |
| OLD | NEW |