| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RECEIVER_CAST_RECEIVER_IMPL_H_ | 5 #ifndef MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_H_ |
| 6 #define MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_H_ | 6 #define MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
| 14 #include "media/cast/cast_receiver.h" | 15 #include "media/cast/cast_receiver.h" |
| 15 #include "media/cast/common/rtp_time.h" | 16 #include "media/cast/common/rtp_time.h" |
| 16 #include "media/cast/net/pacing/paced_sender.h" | 17 #include "media/cast/net/pacing/paced_sender.h" |
| 17 #include "media/cast/receiver/frame_receiver.h" | 18 #include "media/cast/receiver/frame_receiver.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 namespace cast { | 21 namespace cast { |
| 21 | 22 |
| 22 class AudioDecoder; | 23 class AudioDecoder; |
| 23 class VideoDecoder; | 24 class VideoDecoder; |
| 24 | 25 |
| 25 // This is a pure owner class that groups all required receiver-related objects | 26 // This is a pure owner class that groups all required receiver-related objects |
| 26 // together, such as the paced packet sender, audio/video RTP frame receivers, | 27 // together, such as the paced packet sender, audio/video RTP frame receivers, |
| 27 // and software decoders (created on-demand). | 28 // and software decoders (created on-demand). |
| 28 class CastReceiverImpl : public CastReceiver { | 29 class CastReceiverImpl : public CastReceiver { |
| 29 public: | 30 public: |
| 30 CastReceiverImpl(scoped_refptr<CastEnvironment> cast_environment, | 31 CastReceiverImpl(scoped_refptr<CastEnvironment> cast_environment, |
| 31 const FrameReceiverConfig& audio_config, | 32 const FrameReceiverConfig& audio_config, |
| 32 const FrameReceiverConfig& video_config, | 33 const FrameReceiverConfig& video_config, |
| 33 CastTransport* const transport); | 34 CastTransport* const transport); |
| 34 | 35 |
| 35 ~CastReceiverImpl() final; | 36 ~CastReceiverImpl() final; |
| 36 | 37 |
| 37 // CastReceiver implementation. | 38 // CastReceiver implementation. |
| 38 void ReceivePacket(scoped_ptr<Packet> packet) final; | 39 void ReceivePacket(std::unique_ptr<Packet> packet) final; |
| 39 void RequestDecodedAudioFrame( | 40 void RequestDecodedAudioFrame( |
| 40 const AudioFrameDecodedCallback& callback) final; | 41 const AudioFrameDecodedCallback& callback) final; |
| 41 void RequestEncodedAudioFrame( | 42 void RequestEncodedAudioFrame( |
| 42 const ReceiveEncodedFrameCallback& callback) final; | 43 const ReceiveEncodedFrameCallback& callback) final; |
| 43 void RequestDecodedVideoFrame( | 44 void RequestDecodedVideoFrame( |
| 44 const VideoFrameDecodedCallback& callback) final; | 45 const VideoFrameDecodedCallback& callback) final; |
| 45 void RequestEncodedVideoFrame( | 46 void RequestEncodedVideoFrame( |
| 46 const ReceiveEncodedFrameCallback& callback) final; | 47 const ReceiveEncodedFrameCallback& callback) final; |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame() | 50 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame() |
| 50 // uses this as a callback for RequestEncodedAudioFrame(). | 51 // uses this as a callback for RequestEncodedAudioFrame(). |
| 51 void DecodeEncodedAudioFrame( | 52 void DecodeEncodedAudioFrame(const AudioFrameDecodedCallback& callback, |
| 52 const AudioFrameDecodedCallback& callback, | 53 std::unique_ptr<EncodedFrame> encoded_frame); |
| 53 scoped_ptr<EncodedFrame> encoded_frame); | |
| 54 | 54 |
| 55 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame() | 55 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame() |
| 56 // uses this as a callback for RequestEncodedVideoFrame(). | 56 // uses this as a callback for RequestEncodedVideoFrame(). |
| 57 void DecodeEncodedVideoFrame( | 57 void DecodeEncodedVideoFrame(const VideoFrameDecodedCallback& callback, |
| 58 const VideoFrameDecodedCallback& callback, | 58 std::unique_ptr<EncodedFrame> encoded_frame); |
| 59 scoped_ptr<EncodedFrame> encoded_frame); | |
| 60 | 59 |
| 61 // Receives an AudioBus from |audio_decoder_|, logs the event, and passes the | 60 // Receives an AudioBus from |audio_decoder_|, logs the event, and passes the |
| 62 // data on by running the given |callback|. This method is static to ensure | 61 // data on by running the given |callback|. This method is static to ensure |
| 63 // it can be called after a CastReceiverImpl instance is destroyed. | 62 // it can be called after a CastReceiverImpl instance is destroyed. |
| 64 // DecodeEncodedAudioFrame() uses this as a callback for | 63 // DecodeEncodedAudioFrame() uses this as a callback for |
| 65 // AudioDecoder::DecodeFrame(). | 64 // AudioDecoder::DecodeFrame(). |
| 66 static void EmitDecodedAudioFrame( | 65 static void EmitDecodedAudioFrame( |
| 67 const scoped_refptr<CastEnvironment>& cast_environment, | 66 const scoped_refptr<CastEnvironment>& cast_environment, |
| 68 const AudioFrameDecodedCallback& callback, | 67 const AudioFrameDecodedCallback& callback, |
| 69 uint32_t frame_id, | 68 uint32_t frame_id, |
| 70 RtpTimeTicks rtp_timestamp, | 69 RtpTimeTicks rtp_timestamp, |
| 71 const base::TimeTicks& playout_time, | 70 const base::TimeTicks& playout_time, |
| 72 scoped_ptr<AudioBus> audio_bus, | 71 std::unique_ptr<AudioBus> audio_bus, |
| 73 bool is_continuous); | 72 bool is_continuous); |
| 74 | 73 |
| 75 // Receives a VideoFrame from |video_decoder_|, logs the event, and passes the | 74 // Receives a VideoFrame from |video_decoder_|, logs the event, and passes the |
| 76 // data on by running the given |callback|. This method is static to ensure | 75 // data on by running the given |callback|. This method is static to ensure |
| 77 // it can be called after a CastReceiverImpl instance is destroyed. | 76 // it can be called after a CastReceiverImpl instance is destroyed. |
| 78 // DecodeEncodedVideoFrame() uses this as a callback for | 77 // DecodeEncodedVideoFrame() uses this as a callback for |
| 79 // VideoDecoder::DecodeFrame(). | 78 // VideoDecoder::DecodeFrame(). |
| 80 static void EmitDecodedVideoFrame( | 79 static void EmitDecodedVideoFrame( |
| 81 const scoped_refptr<CastEnvironment>& cast_environment, | 80 const scoped_refptr<CastEnvironment>& cast_environment, |
| 82 const VideoFrameDecodedCallback& callback, | 81 const VideoFrameDecodedCallback& callback, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 // Parameters for the decoders that are created on-demand. The values here | 97 // Parameters for the decoders that are created on-demand. The values here |
| 99 // might be nonsense if the client of CastReceiverImpl never intends to use | 98 // might be nonsense if the client of CastReceiverImpl never intends to use |
| 100 // the internal software-based decoders. | 99 // the internal software-based decoders. |
| 101 const int num_audio_channels_; | 100 const int num_audio_channels_; |
| 102 const int audio_sampling_rate_; | 101 const int audio_sampling_rate_; |
| 103 const Codec audio_codec_; | 102 const Codec audio_codec_; |
| 104 const Codec video_codec_; | 103 const Codec video_codec_; |
| 105 | 104 |
| 106 // Created on-demand to decode frames from |audio_receiver_| into AudioBuses | 105 // Created on-demand to decode frames from |audio_receiver_| into AudioBuses |
| 107 // for playback. | 106 // for playback. |
| 108 scoped_ptr<AudioDecoder> audio_decoder_; | 107 std::unique_ptr<AudioDecoder> audio_decoder_; |
| 109 | 108 |
| 110 // Created on-demand to decode frames from |video_receiver_| into VideoFrame | 109 // Created on-demand to decode frames from |video_receiver_| into VideoFrame |
| 111 // images for playback. | 110 // images for playback. |
| 112 scoped_ptr<VideoDecoder> video_decoder_; | 111 std::unique_ptr<VideoDecoder> video_decoder_; |
| 113 | 112 |
| 114 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); | 113 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 } // namespace cast | 116 } // namespace cast |
| 118 } // namespace media | 117 } // namespace media |
| 119 | 118 |
| 120 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_ | 119 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_ |
| OLD | NEW |