| 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/net/pacing/paced_sender.h" |
| 14 #include "media/cast/receiver/frame_receiver.h" | 14 #include "media/cast/receiver/frame_receiver.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 PacketSender* const packet_sender); | 30 CastTransportSender* const transport); |
| 31 | 31 |
| 32 ~CastReceiverImpl() override; | 32 ~CastReceiverImpl() override; |
| 33 | 33 |
| 34 // CastReceiver implementation. | 34 // CastReceiver implementation. |
| 35 PacketReceiverCallback packet_receiver() override; | 35 void ReceivePacket(scoped_ptr<Packet> packet) override; |
| 36 void RequestDecodedAudioFrame( | 36 void RequestDecodedAudioFrame( |
| 37 const AudioFrameDecodedCallback& callback) override; | 37 const AudioFrameDecodedCallback& callback) override; |
| 38 void RequestEncodedAudioFrame( | 38 void RequestEncodedAudioFrame( |
| 39 const ReceiveEncodedFrameCallback& callback) override; | 39 const ReceiveEncodedFrameCallback& callback) override; |
| 40 void RequestDecodedVideoFrame( | 40 void RequestDecodedVideoFrame( |
| 41 const VideoFrameDecodedCallback& callback) override; | 41 const VideoFrameDecodedCallback& callback) override; |
| 42 void RequestEncodedVideoFrame( | 42 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 | |
| 47 // does not map to one of the receivers. | |
| 48 void DispatchReceivedPacket(scoped_ptr<Packet> packet); | |
| 49 | |
| 50 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame() | 46 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame() |
| 51 // uses this as a callback for RequestEncodedAudioFrame(). | 47 // uses this as a callback for RequestEncodedAudioFrame(). |
| 52 void DecodeEncodedAudioFrame( | 48 void DecodeEncodedAudioFrame( |
| 53 const AudioFrameDecodedCallback& callback, | 49 const AudioFrameDecodedCallback& callback, |
| 54 scoped_ptr<EncodedFrame> encoded_frame); | 50 scoped_ptr<EncodedFrame> encoded_frame); |
| 55 | 51 |
| 56 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame() | 52 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame() |
| 57 // uses this as a callback for RequestEncodedVideoFrame(). | 53 // uses this as a callback for RequestEncodedVideoFrame(). |
| 58 void DecodeEncodedVideoFrame( | 54 void DecodeEncodedVideoFrame( |
| 59 const VideoFrameDecodedCallback& callback, | 55 const VideoFrameDecodedCallback& callback, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 81 static void EmitDecodedVideoFrame( | 77 static void EmitDecodedVideoFrame( |
| 82 const scoped_refptr<CastEnvironment>& cast_environment, | 78 const scoped_refptr<CastEnvironment>& cast_environment, |
| 83 const VideoFrameDecodedCallback& callback, | 79 const VideoFrameDecodedCallback& callback, |
| 84 uint32 frame_id, | 80 uint32 frame_id, |
| 85 uint32 rtp_timestamp, | 81 uint32 rtp_timestamp, |
| 86 const base::TimeTicks& playout_time, | 82 const base::TimeTicks& playout_time, |
| 87 const scoped_refptr<VideoFrame>& video_frame, | 83 const scoped_refptr<VideoFrame>& video_frame, |
| 88 bool is_continuous); | 84 bool is_continuous); |
| 89 | 85 |
| 90 const scoped_refptr<CastEnvironment> cast_environment_; | 86 const scoped_refptr<CastEnvironment> cast_environment_; |
| 91 PacedSender pacer_; | |
| 92 FrameReceiver audio_receiver_; | 87 FrameReceiver audio_receiver_; |
| 93 FrameReceiver video_receiver_; | 88 FrameReceiver video_receiver_; |
| 94 | 89 |
| 95 // Used by DispatchReceivedPacket() to direct packets to the appropriate frame | 90 // Used by DispatchReceivedPacket() to direct packets to the appropriate frame |
| 96 // receiver. | 91 // receiver. |
| 97 const uint32 ssrc_of_audio_sender_; | 92 const uint32 ssrc_of_audio_sender_; |
| 98 const uint32 ssrc_of_video_sender_; | 93 const uint32 ssrc_of_video_sender_; |
| 99 | 94 |
| 100 // Parameters for the decoders that are created on-demand. The values here | 95 // 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 | 96 // might be nonsense if the client of CastReceiverImpl never intends to use |
| (...skipping 11 matching lines...) Expand all Loading... |
| 113 // images for playback. | 108 // images for playback. |
| 114 scoped_ptr<VideoDecoder> video_decoder_; | 109 scoped_ptr<VideoDecoder> video_decoder_; |
| 115 | 110 |
| 116 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); | 111 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); |
| 117 }; | 112 }; |
| 118 | 113 |
| 119 } // namespace cast | 114 } // namespace cast |
| 120 } // namespace media | 115 } // namespace media |
| 121 | 116 |
| 122 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_ | 117 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_ |
| OLD | NEW |