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 { | |
26 class PacketSender; | 25 class PacketSender; |
27 } | |
28 | 26 |
29 // The following callbacks are used to deliver decoded audio/video frame data, | 27 // The following callbacks are used to deliver decoded audio/video frame data, |
30 // the frame's corresponding play-out time, and a continuity flag. | 28 // the frame's corresponding play-out time, and a continuity flag. |
31 // |is_continuous| will be false to indicate the loss of data due to a loss of | 29 // |is_continuous| will be false to indicate the loss of data due to a loss of |
32 // frames (or decoding errors). This allows the client to take steps to smooth | 30 // frames (or decoding errors). This allows the client to take steps to smooth |
33 // discontinuities for playback. Note: A NULL pointer can be returned when data | 31 // discontinuities for playback. Note: A NULL pointer can be returned when data |
34 // is not available (e.g., bad/missing packet). | 32 // is not available (e.g., bad/missing packet). |
35 typedef base::Callback<void(scoped_ptr<AudioBus> audio_bus, | 33 typedef base::Callback<void(scoped_ptr<AudioBus> audio_bus, |
36 const base::TimeTicks& playout_time, | 34 const base::TimeTicks& playout_time, |
37 bool is_continuous)> AudioFrameDecodedCallback; | 35 bool is_continuous)> AudioFrameDecodedCallback; |
38 // TODO(miu): |video_frame| includes a timestamp, so use that instead. | 36 // TODO(miu): |video_frame| includes a timestamp, so use that instead. |
39 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, | 37 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, |
40 const base::TimeTicks& playout_time, | 38 const base::TimeTicks& playout_time, |
41 bool is_continuous)> VideoFrameDecodedCallback; | 39 bool is_continuous)> VideoFrameDecodedCallback; |
42 | 40 |
43 // The following callback delivers encoded frame data and metadata. The client | 41 // The following callback delivers encoded frame data and metadata. The client |
44 // should examine the |frame_id| field to determine whether any frames have been | 42 // should examine the |frame_id| field to determine whether any frames have been |
45 // dropped (i.e., frame_id should be incrementing by one each time). Note: A | 43 // dropped (i.e., frame_id should be incrementing by one each time). Note: A |
46 // NULL pointer can be returned on error. | 44 // NULL pointer can be returned on error. |
47 typedef base::Callback<void(scoped_ptr<transport::EncodedFrame>)> | 45 typedef base::Callback<void(scoped_ptr<EncodedFrame>)> |
48 ReceiveEncodedFrameCallback; | 46 ReceiveEncodedFrameCallback; |
49 | 47 |
50 class CastReceiver { | 48 class CastReceiver { |
51 public: | 49 public: |
52 static scoped_ptr<CastReceiver> Create( | 50 static scoped_ptr<CastReceiver> Create( |
53 scoped_refptr<CastEnvironment> cast_environment, | 51 scoped_refptr<CastEnvironment> cast_environment, |
54 const FrameReceiverConfig& audio_config, | 52 const FrameReceiverConfig& audio_config, |
55 const FrameReceiverConfig& video_config, | 53 const FrameReceiverConfig& video_config, |
56 transport::PacketSender* const packet_sender); | 54 PacketSender* const packet_sender); |
57 | 55 |
58 // All received RTP and RTCP packets for the call should be sent to this | 56 // All received RTP and RTCP packets for the call should be sent to this |
59 // PacketReceiver. Can be called from any thread. | 57 // PacketReceiver. Can be called from any thread. |
60 // TODO(hubbe): Replace with: | 58 // TODO(hubbe): Replace with: |
61 // virtual void ReceivePacket(scoped_ptr<Packet> packet) = 0; | 59 // virtual void ReceivePacket(scoped_ptr<Packet> packet) = 0; |
62 virtual transport::PacketReceiverCallback packet_receiver() = 0; | 60 virtual PacketReceiverCallback packet_receiver() = 0; |
63 | 61 |
64 // Polling interface to get audio and video frames from the CastReceiver. The | 62 // Polling interface to get audio and video frames from the CastReceiver. The |
65 // the RequestDecodedXXXXXFrame() methods utilize internal software-based | 63 // the RequestDecodedXXXXXFrame() methods utilize internal software-based |
66 // decoding, while the RequestEncodedXXXXXFrame() methods provides | 64 // decoding, while the RequestEncodedXXXXXFrame() methods provides |
67 // still-encoded frames for use with external/hardware decoders. | 65 // still-encoded frames for use with external/hardware decoders. |
68 // | 66 // |
69 // In all cases, the given |callback| is guaranteed to be run at some point in | 67 // In all cases, the given |callback| is guaranteed to be run at some point in |
70 // the future, except for those requests still enqueued at destruction time. | 68 // the future, except for those requests still enqueued at destruction time. |
71 // | 69 // |
72 // These methods should all be called on the CastEnvironment's MAIN thread. | 70 // These methods should all be called on the CastEnvironment's MAIN thread. |
73 virtual void RequestDecodedAudioFrame( | 71 virtual void RequestDecodedAudioFrame( |
74 const AudioFrameDecodedCallback& callback) = 0; | 72 const AudioFrameDecodedCallback& callback) = 0; |
75 virtual void RequestEncodedAudioFrame( | 73 virtual void RequestEncodedAudioFrame( |
76 const ReceiveEncodedFrameCallback& callback) = 0; | 74 const ReceiveEncodedFrameCallback& callback) = 0; |
77 virtual void RequestDecodedVideoFrame( | 75 virtual void RequestDecodedVideoFrame( |
78 const VideoFrameDecodedCallback& callback) = 0; | 76 const VideoFrameDecodedCallback& callback) = 0; |
79 virtual void RequestEncodedVideoFrame( | 77 virtual void RequestEncodedVideoFrame( |
80 const ReceiveEncodedFrameCallback& callback) = 0; | 78 const ReceiveEncodedFrameCallback& callback) = 0; |
81 | 79 |
82 virtual ~CastReceiver() {} | 80 virtual ~CastReceiver() {} |
83 }; | 81 }; |
84 | 82 |
85 } // namespace cast | 83 } // namespace cast |
86 } // namespace media | 84 } // namespace media |
87 | 85 |
88 #endif // MEDIA_CAST_CAST_RECEIVER_H_ | 86 #endif // MEDIA_CAST_CAST_RECEIVER_H_ |
OLD | NEW |