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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // TODO(miu): |video_frame| includes a timestamp, so use that instead. | 38 // TODO(miu): |video_frame| includes a timestamp, so use that instead. |
39 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, | 39 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, |
40 const base::TimeTicks& playout_time, | 40 const base::TimeTicks& playout_time, |
41 bool is_continuous)> VideoFrameDecodedCallback; | 41 bool is_continuous)> VideoFrameDecodedCallback; |
42 | 42 |
43 // The following callback delivers encoded frame data and metadata. The client | 43 // 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 | 44 // 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 | 45 // dropped (i.e., frame_id should be incrementing by one each time). Note: A |
46 // NULL pointer can be returned on error. | 46 // NULL pointer can be returned on error. |
47 typedef base::Callback<void(scoped_ptr<transport::EncodedFrame>)> | 47 typedef base::Callback<void(scoped_ptr<transport::EncodedFrame>)> |
48 FrameEncodedCallback; | 48 ReceiveEncodedFrameCallback; |
49 | 49 |
50 // This Class is thread safe. | |
51 class FrameReceiver : public base::RefCountedThreadSafe<FrameReceiver> { | |
52 public: | |
53 virtual void GetRawAudioFrame(const AudioFrameDecodedCallback& callback) = 0; | |
54 | |
55 virtual void GetCodedAudioFrame(const FrameEncodedCallback& callback) = 0; | |
56 | |
57 virtual void GetRawVideoFrame(const VideoFrameDecodedCallback& callback) = 0; | |
58 | |
59 virtual void GetEncodedVideoFrame(const FrameEncodedCallback& callback) = 0; | |
60 | |
61 protected: | |
62 virtual ~FrameReceiver() {} | |
63 | |
64 private: | |
65 friend class base::RefCountedThreadSafe<FrameReceiver>; | |
66 }; | |
67 | |
68 // This Class is thread safe. | |
69 class CastReceiver { | 50 class CastReceiver { |
70 public: | 51 public: |
71 static scoped_ptr<CastReceiver> Create( | 52 static scoped_ptr<CastReceiver> Create( |
72 scoped_refptr<CastEnvironment> cast_environment, | 53 scoped_refptr<CastEnvironment> cast_environment, |
73 const FrameReceiverConfig& audio_config, | 54 const FrameReceiverConfig& audio_config, |
74 const FrameReceiverConfig& video_config, | 55 const FrameReceiverConfig& video_config, |
75 transport::PacketSender* const packet_sender); | 56 transport::PacketSender* const packet_sender); |
76 | 57 |
77 // All received RTP and RTCP packets for the call should be sent to this | 58 // All received RTP and RTCP packets for the call should be sent to this |
78 // PacketReceiver. Can be called from any function. | 59 // PacketReceiver. Can be called from any thread. |
79 // TODO(hubbe): Replace with: | 60 // TODO(hubbe): Replace with: |
80 // virtual void ReceivePacket(scoped_ptr<Packet> packet) = 0; | 61 // virtual void ReceivePacket(scoped_ptr<Packet> packet) = 0; |
81 virtual transport::PacketReceiverCallback packet_receiver() = 0; | 62 virtual transport::PacketReceiverCallback packet_receiver() = 0; |
82 | 63 |
83 // Polling interface to get audio and video frames from the CastReceiver. | 64 // Polling interface to get audio and video frames from the CastReceiver. The |
84 virtual scoped_refptr<FrameReceiver> frame_receiver() = 0; | 65 // the RequestDecodedXXXXXFrame() methods utilize internal software-based |
| 66 // decoding, while the RequestEncodedXXXXXFrame() methods provides |
| 67 // still-encoded frames for use with external/hardware decoders. |
| 68 // |
| 69 // 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. |
| 71 // |
| 72 // These methods should all be called on the CastEnvironment's MAIN thread. |
| 73 virtual void RequestDecodedAudioFrame( |
| 74 const AudioFrameDecodedCallback& callback) = 0; |
| 75 virtual void RequestEncodedAudioFrame( |
| 76 const ReceiveEncodedFrameCallback& callback) = 0; |
| 77 virtual void RequestDecodedVideoFrame( |
| 78 const VideoFrameDecodedCallback& callback) = 0; |
| 79 virtual void RequestEncodedVideoFrame( |
| 80 const ReceiveEncodedFrameCallback& callback) = 0; |
85 | 81 |
86 virtual ~CastReceiver() {} | 82 virtual ~CastReceiver() {} |
87 }; | 83 }; |
88 | 84 |
89 } // namespace cast | 85 } // namespace cast |
90 } // namespace media | 86 } // namespace media |
91 | 87 |
92 #endif // MEDIA_CAST_CAST_RECEIVER_H_ | 88 #endif // MEDIA_CAST_CAST_RECEIVER_H_ |
OLD | NEW |