Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: media/cast/cast_sender.h

Issue 163553006: Cast: Refactoring Cast API's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactoring and responding to review Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
6 // at creation.
7 // 6 //
8 // The FrameInput and PacketReciever interfaces should normally be accessed from 7 // The AudioFrameInput, VideoFrameInput and PacketReciever interfaces should
9 // the IO thread. However they are allowed to be called from any thread. 8 // be accessed from the IO thread. However they may be called from any thread.
Alpha Left Google 2014/02/18 22:28:13 media/cast has no concept of an "IO" thread. This
mikhal1 2014/03/05 21:44:05 Done.
10 9
11 #ifndef MEDIA_CAST_CAST_SENDER_H_ 10 #ifndef MEDIA_CAST_CAST_SENDER_H_
12 #define MEDIA_CAST_CAST_SENDER_H_ 11 #define MEDIA_CAST_CAST_SENDER_H_
13 12
14 #include "base/basictypes.h" 13 #include "base/basictypes.h"
15 #include "base/callback.h" 14 #include "base/callback.h"
16 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
17 #include "base/time/tick_clock.h" 16 #include "base/time/tick_clock.h"
18 #include "base/time/time.h" 17 #include "base/time/time.h"
19 #include "media/cast/cast_config.h" 18 #include "media/cast/cast_config.h"
20 #include "media/cast/cast_environment.h" 19 #include "media/cast/cast_environment.h"
21 #include "media/cast/transport/cast_transport_sender.h" 20 #include "media/cast/transport/cast_transport_sender.h"
22 #include "media/filters/gpu_video_accelerator_factories.h" 21 #include "media/filters/gpu_video_accelerator_factories.h"
23 22
24 namespace media { 23 namespace media {
25 class AudioBus; 24 class AudioBus;
25 class GpuVideoAcceleratorFactories;
26 class VideoFrame; 26 class VideoFrame;
27 }
28 27
29 namespace media {
30 namespace cast { 28 namespace cast {
29 class AudioSender;
30 class VideoSender;
31 31
32 // This Class is thread safe. 32 class VideoFrameInput : public base::RefCountedThreadSafe<VideoFrameInput> {
33 class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
34 public: 33 public:
35 // The video_frame must be valid until the callback is called. 34 // Insert video frames into Cast sender. Frames will be encoded, packetized
36 // The callback is called from the main cast thread as soon as 35 // and sent to the network.
37 // the encoder is done with the frame; it does not mean that the encoded frame
38 // has been sent out.
39 virtual void InsertRawVideoFrame( 36 virtual void InsertRawVideoFrame(
40 const scoped_refptr<media::VideoFrame>& video_frame, 37 const scoped_refptr<media::VideoFrame>& video_frame,
41 const base::TimeTicks& capture_time) = 0; 38 const base::TimeTicks& capture_time) = 0;
42 39
40 protected:
41 virtual ~VideoFrameInput() {}
42
43 private:
44 friend class base::RefCountedThreadSafe<VideoFrameInput>;
45 };
46
47 class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> {
48 public:
49 // Insert audio frames into Cast sender. Frames will be encoded, packetized
50 // and sent to the network.
43 // The |audio_bus| must be valid until the |done_callback| is called. 51 // The |audio_bus| must be valid until the |done_callback| is called.
44 // The callback is called from the main cast thread as soon as the encoder is 52 // The callback is called from the main cast thread as soon as the encoder is
45 // done with |audio_bus|; it does not mean that the encoded data has been 53 // done with |audio_bus|; it does not mean that the encoded data has been
46 // sent out. 54 // sent out.
47 virtual void InsertAudio(const AudioBus* audio_bus, 55 virtual void InsertAudio(const AudioBus* audio_bus,
48 const base::TimeTicks& recorded_time, 56 const base::TimeTicks& recorded_time,
49 const base::Closure& done_callback) = 0; 57 const base::Closure& done_callback) = 0;
50 58
51 protected: 59 protected:
52 virtual ~FrameInput() {} 60 virtual ~AudioFrameInput() {}
53 61
54 private: 62 private:
55 friend class base::RefCountedThreadSafe<FrameInput>; 63 friend class base::RefCountedThreadSafe<AudioFrameInput>;
56 }; 64 };
57 65
58 // This Class is thread safe. 66 // This Class is thread safe.
Alpha Left Google 2014/02/18 22:28:13 This is actually not true. You might as well say a
mikhal1 2014/03/05 21:44:05 Done.
59 // The provided CastTransportSender object will always be called from the main 67 // The provided CastTransportSender object will always be called from the main
60 // cast thread. 68 // cast thread.
61 // At least one of AudioSenderConfig and VideoSenderConfig have to be provided.
62 class CastSender { 69 class CastSender {
63 public: 70 public:
64 static CastSender* CreateCastSender( 71 static scoped_ptr<CastSender> Create(
65 scoped_refptr<CastEnvironment> cast_environment, 72 scoped_refptr<CastEnvironment> cast_environment,
66 const AudioSenderConfig* audio_config, 73 const CastInitializationCallback& cast_initialization_cb,
67 const VideoSenderConfig* video_config,
68 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
69 const CastInitializationCallback& cast_initialization,
70 transport::CastTransportSender* const transport_sender); 74 transport::CastTransportSender* const transport_sender);
71 75
72 virtual ~CastSender() {} 76 virtual ~CastSender() {}
73 77
74 // All audio and video frames for the session should be inserted to this 78 // All video frames for the session should be inserted to this object.
75 // object.
76 // Can be called from any thread. 79 // Can be called from any thread.
Alpha Left Google 2014/02/18 22:28:13 This can only be called on the main thread because
mikhal1 2014/03/05 21:44:05 Done.
mikhal1 2014/03/05 21:44:05 Done.
77 virtual scoped_refptr<FrameInput> frame_input() = 0; 80 virtual scoped_refptr<VideoFrameInput> video_frame_input() = 0;
81
82 // All audio frames for the session should be inserted to this object.
83 // Can be called from any thread.
Alpha Left Google 2014/02/18 22:28:13 This can only be called on the main thread.
mikhal1 2014/03/05 21:44:05 Done.
mikhal1 2014/03/05 21:44:05 Done.
84 virtual scoped_refptr<AudioFrameInput> audio_frame_input() = 0;
78 85
79 // All RTCP packets for the session should be inserted to this object. 86 // All RTCP packets for the session should be inserted to this object.
80 // Can be called from any thread. 87 // This function and the callback must be called on the main thread.
81 virtual transport::PacketReceiverCallback packet_receiver() = 0; 88 virtual transport::PacketReceiverCallback packet_receiver() = 0;
89
90 // Initialize the audio stack. Must be called in order to send audio frames.
91 virtual void InitializeAudio(const AudioSenderConfig& audio_config) = 0;
Alpha Left Google 2014/02/18 22:28:13 These two methods should be called on the main thr
mikhal1 2014/03/05 21:44:05 Done.
92
93 // Initialize the video stack. Must be called in order to send video frames.
94 virtual void InitializeVideo(
95 const VideoSenderConfig& video_config,
96 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories) = 0;
82 }; 97 };
83 98
84 } // namespace cast 99 } // namespace cast
85 } // namespace media 100 } // namespace media
86 101
87 #endif // MEDIA_CAST_CAST_SENDER_H_ 102 #endif // MEDIA_CAST_CAST_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698