| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "media/cast/cast_config.h" | 10 #include "media/cast/cast_config.h" |
| 11 #include "media/cast/cast_environment.h" | 11 #include "media/cast/cast_environment.h" |
| 12 #include "media/cast/cast_receiver.h" | 12 #include "media/cast/cast_receiver.h" |
| 13 #include "media/cast/net/pacing/paced_sender.h" |
| 13 #include "media/cast/receiver/frame_receiver.h" | 14 #include "media/cast/receiver/frame_receiver.h" |
| 14 #include "media/cast/transport/pacing/paced_sender.h" | |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 namespace cast { | 17 namespace cast { |
| 18 | 18 |
| 19 class AudioDecoder; | 19 class AudioDecoder; |
| 20 class VideoDecoder; | 20 class VideoDecoder; |
| 21 | 21 |
| 22 // This is a pure owner class that groups all required receiver-related objects | 22 // This is a pure owner class that groups all required receiver-related objects |
| 23 // together, such as the paced packet sender, audio/video RTP frame receivers, | 23 // together, such as the paced packet sender, audio/video RTP frame receivers, |
| 24 // and software decoders (created on-demand). | 24 // and software decoders (created on-demand). |
| 25 class CastReceiverImpl : public CastReceiver { | 25 class CastReceiverImpl : public CastReceiver { |
| 26 public: | 26 public: |
| 27 CastReceiverImpl(scoped_refptr<CastEnvironment> cast_environment, | 27 CastReceiverImpl(scoped_refptr<CastEnvironment> cast_environment, |
| 28 const FrameReceiverConfig& audio_config, | 28 const FrameReceiverConfig& audio_config, |
| 29 const FrameReceiverConfig& video_config, | 29 const FrameReceiverConfig& video_config, |
| 30 transport::PacketSender* const packet_sender); | 30 PacketSender* const packet_sender); |
| 31 | 31 |
| 32 virtual ~CastReceiverImpl(); | 32 virtual ~CastReceiverImpl(); |
| 33 | 33 |
| 34 // CastReceiver implementation. | 34 // CastReceiver implementation. |
| 35 virtual transport::PacketReceiverCallback packet_receiver() OVERRIDE; | 35 virtual PacketReceiverCallback packet_receiver() OVERRIDE; |
| 36 virtual void RequestDecodedAudioFrame( | 36 virtual void RequestDecodedAudioFrame( |
| 37 const AudioFrameDecodedCallback& callback) OVERRIDE; | 37 const AudioFrameDecodedCallback& callback) OVERRIDE; |
| 38 virtual void RequestEncodedAudioFrame( | 38 virtual void RequestEncodedAudioFrame( |
| 39 const ReceiveEncodedFrameCallback& callback) OVERRIDE; | 39 const ReceiveEncodedFrameCallback& callback) OVERRIDE; |
| 40 virtual void RequestDecodedVideoFrame( | 40 virtual void RequestDecodedVideoFrame( |
| 41 const VideoFrameDecodedCallback& callback) OVERRIDE; | 41 const VideoFrameDecodedCallback& callback) OVERRIDE; |
| 42 virtual void RequestEncodedVideoFrame( | 42 virtual void RequestEncodedVideoFrame( |
| 43 const ReceiveEncodedFrameCallback& callback) OVERRIDE; | 43 const ReceiveEncodedFrameCallback& callback) OVERRIDE; |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 // Forwards |packet| to a specific RTP frame receiver, or drops it if SSRC | 46 // Forwards |packet| to a specific RTP frame receiver, or drops it if SSRC |
| 47 // does not map to one of the receivers. | 47 // does not map to one of the receivers. |
| 48 void DispatchReceivedPacket(scoped_ptr<Packet> packet); | 48 void DispatchReceivedPacket(scoped_ptr<Packet> packet); |
| 49 | 49 |
| 50 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame() | 50 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame() |
| 51 // uses this as a callback for RequestEncodedAudioFrame(). | 51 // uses this as a callback for RequestEncodedAudioFrame(). |
| 52 void DecodeEncodedAudioFrame( | 52 void DecodeEncodedAudioFrame( |
| 53 const AudioFrameDecodedCallback& callback, | 53 const AudioFrameDecodedCallback& callback, |
| 54 scoped_ptr<transport::EncodedFrame> encoded_frame); | 54 scoped_ptr<EncodedFrame> encoded_frame); |
| 55 | 55 |
| 56 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame() | 56 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame() |
| 57 // uses this as a callback for RequestEncodedVideoFrame(). | 57 // uses this as a callback for RequestEncodedVideoFrame(). |
| 58 void DecodeEncodedVideoFrame( | 58 void DecodeEncodedVideoFrame( |
| 59 const VideoFrameDecodedCallback& callback, | 59 const VideoFrameDecodedCallback& callback, |
| 60 scoped_ptr<transport::EncodedFrame> encoded_frame); | 60 scoped_ptr<EncodedFrame> encoded_frame); |
| 61 | 61 |
| 62 // Receives an AudioBus from |audio_decoder_|, logs the event, and passes the | 62 // Receives an AudioBus from |audio_decoder_|, logs the event, and passes the |
| 63 // data on by running the given |callback|. This method is static to ensure | 63 // data on by running the given |callback|. This method is static to ensure |
| 64 // it can be called after a CastReceiverImpl instance is destroyed. | 64 // it can be called after a CastReceiverImpl instance is destroyed. |
| 65 // DecodeEncodedAudioFrame() uses this as a callback for | 65 // DecodeEncodedAudioFrame() uses this as a callback for |
| 66 // AudioDecoder::DecodeFrame(). | 66 // AudioDecoder::DecodeFrame(). |
| 67 static void EmitDecodedAudioFrame( | 67 static void EmitDecodedAudioFrame( |
| 68 const scoped_refptr<CastEnvironment>& cast_environment, | 68 const scoped_refptr<CastEnvironment>& cast_environment, |
| 69 const AudioFrameDecodedCallback& callback, | 69 const AudioFrameDecodedCallback& callback, |
| 70 uint32 frame_id, | 70 uint32 frame_id, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 81 static void EmitDecodedVideoFrame( | 81 static void EmitDecodedVideoFrame( |
| 82 const scoped_refptr<CastEnvironment>& cast_environment, | 82 const scoped_refptr<CastEnvironment>& cast_environment, |
| 83 const VideoFrameDecodedCallback& callback, | 83 const VideoFrameDecodedCallback& callback, |
| 84 uint32 frame_id, | 84 uint32 frame_id, |
| 85 uint32 rtp_timestamp, | 85 uint32 rtp_timestamp, |
| 86 const base::TimeTicks& playout_time, | 86 const base::TimeTicks& playout_time, |
| 87 const scoped_refptr<VideoFrame>& video_frame, | 87 const scoped_refptr<VideoFrame>& video_frame, |
| 88 bool is_continuous); | 88 bool is_continuous); |
| 89 | 89 |
| 90 const scoped_refptr<CastEnvironment> cast_environment_; | 90 const scoped_refptr<CastEnvironment> cast_environment_; |
| 91 transport::PacedSender pacer_; | 91 PacedSender pacer_; |
| 92 FrameReceiver audio_receiver_; | 92 FrameReceiver audio_receiver_; |
| 93 FrameReceiver video_receiver_; | 93 FrameReceiver video_receiver_; |
| 94 | 94 |
| 95 // Used by DispatchReceivedPacket() to direct packets to the appropriate frame | 95 // Used by DispatchReceivedPacket() to direct packets to the appropriate frame |
| 96 // receiver. | 96 // receiver. |
| 97 const uint32 ssrc_of_audio_sender_; | 97 const uint32 ssrc_of_audio_sender_; |
| 98 const uint32 ssrc_of_video_sender_; | 98 const uint32 ssrc_of_video_sender_; |
| 99 | 99 |
| 100 // Parameters for the decoders that are created on-demand. The values here | 100 // Parameters for the decoders that are created on-demand. The values here |
| 101 // might be nonsense if the client of CastReceiverImpl never intends to use | 101 // might be nonsense if the client of CastReceiverImpl never intends to use |
| 102 // the internal software-based decoders. | 102 // the internal software-based decoders. |
| 103 const int num_audio_channels_; | 103 const int num_audio_channels_; |
| 104 const int audio_sampling_rate_; | 104 const int audio_sampling_rate_; |
| 105 const transport::Codec audio_codec_; | 105 const Codec audio_codec_; |
| 106 const transport::Codec video_codec_; | 106 const Codec video_codec_; |
| 107 | 107 |
| 108 // Created on-demand to decode frames from |audio_receiver_| into AudioBuses | 108 // Created on-demand to decode frames from |audio_receiver_| into AudioBuses |
| 109 // for playback. | 109 // for playback. |
| 110 scoped_ptr<AudioDecoder> audio_decoder_; | 110 scoped_ptr<AudioDecoder> audio_decoder_; |
| 111 | 111 |
| 112 // Created on-demand to decode frames from |video_receiver_| into VideoFrame | 112 // Created on-demand to decode frames from |video_receiver_| into VideoFrame |
| 113 // images for playback. | 113 // images for playback. |
| 114 scoped_ptr<VideoDecoder> video_decoder_; | 114 scoped_ptr<VideoDecoder> video_decoder_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); | 116 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 } // namespace cast | 119 } // namespace cast |
| 120 } // namespace media | 120 } // namespace media |
| 121 | 121 |
| 122 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_ | 122 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_ |
| OLD | NEW |