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 sender. All configuration are done | 5 // This is the main interface for the cast sender. All configuration are done |
6 // at creation. | 6 // at creation. |
7 // | 7 // |
8 // The FrameInput and PacketReciever interfaces should normally be accessed from | 8 // The FrameInput and PacketReciever interfaces should normally be accessed from |
9 // the IO thread. However they are allowed to be called from any thread. | 9 // the IO thread. However they are allowed to be called from any thread. |
10 | 10 |
11 #ifndef MEDIA_CAST_CAST_SENDER_H_ | 11 #ifndef MEDIA_CAST_CAST_SENDER_H_ |
12 #define MEDIA_CAST_CAST_SENDER_H_ | 12 #define MEDIA_CAST_CAST_SENDER_H_ |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/time/tick_clock.h" | 17 #include "base/time/tick_clock.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "media/cast/cast_config.h" | 19 #include "media/cast/cast_config.h" |
20 #include "media/cast/cast_environment.h" | 20 #include "media/cast/cast_environment.h" |
| 21 #include "media/filters/gpu_video_accelerator_factories.h" |
21 | 22 |
22 namespace media { | 23 namespace media { |
23 class AudioBus; | 24 class AudioBus; |
24 class VideoFrame; | 25 class VideoFrame; |
25 } | 26 } |
26 | 27 |
27 namespace media { | 28 namespace media { |
28 namespace cast { | 29 namespace cast { |
29 | 30 |
30 // This Class is thread safe. | 31 // This Class is thread safe. |
31 class FrameInput : public base::RefCountedThreadSafe<FrameInput> { | 32 class FrameInput : public base::RefCountedThreadSafe<FrameInput> { |
32 public: | 33 public: |
33 // The video_frame must be valid until the callback is called. | 34 // The video_frame must be valid until the callback is called. |
34 // The callback is called from the main cast thread as soon as | 35 // The callback is called from the main cast thread as soon as |
35 // the encoder is done with the frame; it does not mean that the encoded frame | 36 // the encoder is done with the frame; it does not mean that the encoded frame |
36 // has been sent out. | 37 // has been sent out. |
37 virtual void InsertRawVideoFrame( | 38 virtual void InsertRawVideoFrame( |
38 const scoped_refptr<media::VideoFrame>& video_frame, | 39 const scoped_refptr<media::VideoFrame>& video_frame, |
39 const base::TimeTicks& capture_time) = 0; | 40 const base::TimeTicks& capture_time) = 0; |
40 | 41 |
41 // The video_frame must be valid until the callback is called. | |
42 // The callback is called from the main cast thread as soon as | |
43 // the cast sender is done with the frame; it does not mean that the encoded | |
44 // frame has been sent out. | |
45 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, | |
46 const base::TimeTicks& capture_time, | |
47 const base::Closure callback) = 0; | |
48 | |
49 // The |audio_bus| must be valid until the |done_callback| is called. | 42 // The |audio_bus| must be valid until the |done_callback| is called. |
50 // The callback is called from the main cast thread as soon as the encoder is | 43 // The callback is called from the main cast thread as soon as the encoder is |
51 // done with |audio_bus|; it does not mean that the encoded data has been | 44 // done with |audio_bus|; it does not mean that the encoded data has been |
52 // sent out. | 45 // sent out. |
53 virtual void InsertAudio(const AudioBus* audio_bus, | 46 virtual void InsertAudio(const AudioBus* audio_bus, |
54 const base::TimeTicks& recorded_time, | 47 const base::TimeTicks& recorded_time, |
55 const base::Closure& done_callback) = 0; | 48 const base::Closure& done_callback) = 0; |
56 | 49 |
57 // The audio_frame must be valid until the callback is called. | 50 // The audio_frame must be valid until the callback is called. |
58 // The callback is called from the main cast thread as soon as | 51 // The callback is called from the main cast thread as soon as |
(...skipping 12 matching lines...) Expand all Loading... |
71 | 64 |
72 // This Class is thread safe. | 65 // This Class is thread safe. |
73 // The provided PacketSender object will always be called form the main cast | 66 // The provided PacketSender object will always be called form the main cast |
74 // thread. | 67 // thread. |
75 class CastSender { | 68 class CastSender { |
76 public: | 69 public: |
77 static CastSender* CreateCastSender( | 70 static CastSender* CreateCastSender( |
78 scoped_refptr<CastEnvironment> cast_environment, | 71 scoped_refptr<CastEnvironment> cast_environment, |
79 const AudioSenderConfig& audio_config, | 72 const AudioSenderConfig& audio_config, |
80 const VideoSenderConfig& video_config, | 73 const VideoSenderConfig& video_config, |
81 VideoEncoderController* const video_encoder_controller, | 74 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, |
82 PacketSender* const packet_sender); | 75 PacketSender* const packet_sender); |
| 76 // TODO(pwestin): Add callback for status messages; initialized, errors etc. |
83 | 77 |
84 virtual ~CastSender() {} | 78 virtual ~CastSender() {} |
85 | 79 |
86 // All audio and video frames for the session should be inserted to this | 80 // All audio and video frames for the session should be inserted to this |
87 // object. | 81 // object. |
88 // Can be called from any thread. | 82 // Can be called from any thread. |
89 virtual scoped_refptr<FrameInput> frame_input() = 0; | 83 virtual scoped_refptr<FrameInput> frame_input() = 0; |
90 | 84 |
91 // All RTCP packets for the session should be inserted to this object. | 85 // All RTCP packets for the session should be inserted to this object. |
92 // Can be called from any thread. | 86 // Can be called from any thread. |
93 virtual scoped_refptr<PacketReceiver> packet_receiver() = 0; | 87 virtual scoped_refptr<PacketReceiver> packet_receiver() = 0; |
94 }; | 88 }; |
95 | 89 |
96 } // namespace cast | 90 } // namespace cast |
97 } // namespace media | 91 } // namespace media |
98 | 92 |
99 #endif // MEDIA_CAST_CAST_SENDER_H_ | 93 #endif // MEDIA_CAST_CAST_SENDER_H_ |
OLD | NEW |