| 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 // This is the main interface for the cast receiver. All configuration are done | 5 // This is the main interface for the cast receiver. All configuration are done |
| 6 // at creation. | 6 // at creation. |
| 7 | 7 |
| 8 #ifndef MEDIA_CAST_CAST_RECEIVER_H_ | 8 #ifndef MEDIA_CAST_CAST_RECEIVER_H_ |
| 9 #define MEDIA_CAST_CAST_RECEIVER_H_ | 9 #define MEDIA_CAST_CAST_RECEIVER_H_ |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "media/base/audio_bus.h" | 16 #include "media/base/audio_bus.h" |
| 17 #include "media/cast/cast_config.h" | 17 #include "media/cast/cast_config.h" |
| 18 #include "media/cast/cast_environment.h" | 18 #include "media/cast/cast_environment.h" |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 class VideoFrame; | 21 class VideoFrame; |
| 22 | 22 |
| 23 namespace cast { | 23 namespace cast { |
| 24 | 24 |
| 25 namespace transport { | 25 namespace transport { |
| 26 class PacketSender; | 26 class PacketSender; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Callback in which the raw audio frame, play-out time, and a continuity flag | 29 // The following callbacks are used to deliver decoded audio/video frame data, |
| 30 // will be returned. |is_continuous| will be false to indicate the loss of | 30 // the frame's corresponding play-out time, and a continuity flag. |
| 31 // audio data due to a loss of frames (or decoding errors). This allows the | 31 // |is_continuous| will be false to indicate the loss of data due to a loss of |
| 32 // client to take steps to smooth discontinuities for playback. Note: A NULL | 32 // frames (or decoding errors). This allows the client to take steps to smooth |
| 33 // AudioBus can be returned when data is not available (e.g., bad packet or when | 33 // discontinuities for playback. Note: A NULL pointer can be returned when data |
| 34 // flushing callbacks during shutdown). | 34 // is not available (e.g., bad packet or when flushing callbacks during |
| 35 // shutdown). |
| 35 typedef base::Callback<void(scoped_ptr<AudioBus> audio_bus, | 36 typedef base::Callback<void(scoped_ptr<AudioBus> audio_bus, |
| 36 const base::TimeTicks& playout_time, | 37 const base::TimeTicks& playout_time, |
| 37 bool is_continuous)> AudioFrameDecodedCallback; | 38 bool is_continuous)> AudioFrameDecodedCallback; |
| 39 // TODO(miu): |video_frame| includes a timestamp, so use that instead. |
| 40 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, |
| 41 const base::TimeTicks& playout_time, |
| 42 bool is_continuous)> VideoFrameDecodedCallback; |
| 38 | 43 |
| 39 // Callback in which the encoded audio frame and play-out time will be | 44 // The following callbacks deliver still-encoded audio/video frame data, along |
| 40 // returned. The client should examine the EncodedAudioFrame::frame_id field to | 45 // with the frame's corresponding play-out time. The client should examine the |
| 41 // determine whether any frames have been dropped (i.e., frame_id should be | 46 // EncodedXXXFrame::frame_id field to determine whether any frames have been |
| 42 // incrementing by one each time). Note: A NULL EncodedAudioFrame can be | 47 // dropped (i.e., frame_id should be incrementing by one each time). Note: A |
| 43 // returned on error/shutdown. | 48 // NULL pointer can be returned on error/shutdown. |
| 44 typedef base::Callback<void(scoped_ptr<transport::EncodedAudioFrame>, | 49 typedef base::Callback<void(scoped_ptr<transport::EncodedAudioFrame>, |
| 45 const base::TimeTicks&)> AudioFrameEncodedCallback; | 50 const base::TimeTicks&)> AudioFrameEncodedCallback; |
| 46 | |
| 47 // Callback in which the raw frame and render time will be returned once | |
| 48 // decoding is complete. | |
| 49 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, | |
| 50 const base::TimeTicks&)> VideoFrameDecodedCallback; | |
| 51 | |
| 52 // Callback in which the encoded video frame and render time will be returned. | |
| 53 typedef base::Callback<void(scoped_ptr<transport::EncodedVideoFrame>, | 51 typedef base::Callback<void(scoped_ptr<transport::EncodedVideoFrame>, |
| 54 const base::TimeTicks&)> VideoFrameEncodedCallback; | 52 const base::TimeTicks&)> VideoFrameEncodedCallback; |
| 55 | 53 |
| 56 // This Class is thread safe. | 54 // This Class is thread safe. |
| 57 class FrameReceiver : public base::RefCountedThreadSafe<FrameReceiver> { | 55 class FrameReceiver : public base::RefCountedThreadSafe<FrameReceiver> { |
| 58 public: | 56 public: |
| 59 virtual void GetRawAudioFrame(const AudioFrameDecodedCallback& callback) = 0; | 57 virtual void GetRawAudioFrame(const AudioFrameDecodedCallback& callback) = 0; |
| 60 | 58 |
| 61 virtual void GetCodedAudioFrame( | 59 virtual void GetCodedAudioFrame( |
| 62 const AudioFrameEncodedCallback& callback) = 0; | 60 const AudioFrameEncodedCallback& callback) = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 // Polling interface to get audio and video frames from the CastReceiver. | 89 // Polling interface to get audio and video frames from the CastReceiver. |
| 92 virtual scoped_refptr<FrameReceiver> frame_receiver() = 0; | 90 virtual scoped_refptr<FrameReceiver> frame_receiver() = 0; |
| 93 | 91 |
| 94 virtual ~CastReceiver() {} | 92 virtual ~CastReceiver() {} |
| 95 }; | 93 }; |
| 96 | 94 |
| 97 } // namespace cast | 95 } // namespace cast |
| 98 } // namespace media | 96 } // namespace media |
| 99 | 97 |
| 100 #endif // MEDIA_CAST_CAST_RECEIVER_H_ | 98 #endif // MEDIA_CAST_CAST_RECEIVER_H_ |
| OLD | NEW |