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

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: 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. 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/cast/transport/cast_transport_sender.h" 21 #include "media/cast/transport/cast_transport_sender.h"
22 #include "media/filters/gpu_video_accelerator_factories.h" 22 #include "media/filters/gpu_video_accelerator_factories.h"
23 23
24 namespace media { 24 namespace media {
25 class AudioBus; 25 class AudioBus;
26 class GpuVideoAcceleratorFactories;
26 class VideoFrame; 27 class VideoFrame;
27 }
28 28
29 namespace media {
30 namespace cast { 29 namespace cast {
30 class AudioSender;
31 class VideoSender;
32
31 33
32 // This Class is thread safe. 34 // This Class is thread safe.
Ami GONE FROM CHROMIUM 2014/02/13 18:02:14 "thread safe" usually implies callable from any th
mikhal1 2014/02/14 18:03:16 Comment irrelevant. New comments added. On 2014/02
33 class FrameInput : public base::RefCountedThreadSafe<FrameInput> { 35 class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
34 public: 36 public:
35 // The video_frame must be valid until the callback is called. 37 // The video_frame must be valid until the callback is called.
36 // The callback is called from the main cast thread as soon as 38 // The callback is called from the main cast thread as soon as
37 // the encoder is done with the frame; it does not mean that the encoded frame 39 // the encoder is done with the frame; it does not mean that the encoded frame
38 // has been sent out. 40 // has been sent out.
39 virtual void InsertRawVideoFrame( 41 virtual void InsertRawVideoFrame(
40 const scoped_refptr<media::VideoFrame>& video_frame, 42 const scoped_refptr<media::VideoFrame>& video_frame,
41 const base::TimeTicks& capture_time) = 0; 43 const base::TimeTicks& capture_time) = 0;
42 44
43 // The |audio_bus| must be valid until the |done_callback| is called. 45 // 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 46 // 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 47 // done with |audio_bus|; it does not mean that the encoded data has been
46 // sent out. 48 // sent out.
47 virtual void InsertAudio(const AudioBus* audio_bus, 49 virtual void InsertAudio(const AudioBus* audio_bus,
48 const base::TimeTicks& recorded_time, 50 const base::TimeTicks& recorded_time,
49 const base::Closure& done_callback) = 0; 51 const base::Closure& done_callback) = 0;
50 52
53 virtual void SetAudioSender(base::WeakPtr<AudioSender> audio_sender) = 0;
Ami GONE FROM CHROMIUM 2014/02/13 18:02:14 doco (esp. for public, esp^2 for pure virtual)
mikhal1 2014/02/14 18:03:16 Done.
54
55 virtual void SetVideoSender(base::WeakPtr<VideoSender> video_sender) = 0;
56
51 protected: 57 protected:
52 virtual ~FrameInput() {} 58 virtual ~FrameInput() {}
53 59
54 private: 60 private:
55 friend class base::RefCountedThreadSafe<FrameInput>; 61 friend class base::RefCountedThreadSafe<FrameInput>;
56 }; 62 };
57 63
58 // This Class is thread safe. 64 // This Class is thread safe.
59 // The provided CastTransportSender object will always be called from the main 65 // The provided CastTransportSender object will always be called from the main
60 // cast thread. 66 // cast thread.
61 // At least one of AudioSenderConfig and VideoSenderConfig have to be provided. 67 // At least one of AudioSenderConfig and VideoSenderConfig have to be provided.
62 class CastSender { 68 class CastSender {
63 public: 69 public:
64 static CastSender* CreateCastSender( 70 static CastSender* CreateCastSender(
Ami GONE FROM CHROMIUM 2014/02/13 18:02:14 This doesn't doco ownership semantics of the retur
Alpha Left Google 2014/02/13 19:53:59 This can just be CastSender::Create(...). CastSend
mikhal1 2014/02/14 18:03:16 Renamed. On 2014/02/13 19:53:59, Alpha wrote:
65 scoped_refptr<CastEnvironment> cast_environment, 71 scoped_refptr<CastEnvironment> cast_environment,
66 const AudioSenderConfig* audio_config,
67 const VideoSenderConfig* video_config,
68 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
69 const CastInitializationCallback& cast_initialization, 72 const CastInitializationCallback& cast_initialization,
70 transport::CastTransportSender* const transport_sender); 73 transport::CastTransportSender* const transport_sender);
71 74
72 virtual ~CastSender() {} 75 virtual ~CastSender() {}
73 76
74 // All audio and video frames for the session should be inserted to this 77 // All audio and video frames for the session should be inserted to this
75 // object. 78 // object.
76 // Can be called from any thread. 79 // Can be called from any thread.
77 virtual scoped_refptr<FrameInput> frame_input() = 0; 80 virtual scoped_refptr<FrameInput> frame_input() = 0;
78 81
79 // All RTCP packets for the session should be inserted to this object. 82 // All RTCP packets for the session should be inserted to this object.
80 // Can be called from any thread. 83 // Can be called from any thread.
81 virtual transport::PacketReceiverCallback packet_receiver() = 0; 84 virtual transport::PacketReceiverCallback packet_receiver() = 0;
85
86 // Initialize the audio stack. Must be called in order to send audio frames.
87 virtual void InitializeAudio(const AudioSenderConfig& audio_config) = 0;
88
89 // Initialize the video stack. Must be called in order to send video frames.
90 virtual void InitializeVideo(
91 const VideoSenderConfig& video_config,
92 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories) = 0;
82 }; 93 };
83 94
84 } // namespace cast 95 } // namespace cast
85 } // namespace media 96 } // namespace media
86 97
87 #endif // MEDIA_CAST_CAST_SENDER_H_ 98 #endif // MEDIA_CAST_CAST_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698