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

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: 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. 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.
Ami GONE FROM CHROMIUM 2014/02/14 18:23:54 no longer true
mikhal1 2014/02/18 19:20:43 Code refactored. On 2014/02/14 18:23:54, Ami Fisch
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;
31 32
32 // This Class is thread safe.
33 class FrameInput : public base::RefCountedThreadSafe<FrameInput> { 33 class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
34 public: 34 public:
35 // The video_frame must be valid until the callback is called. 35 // The video_frame must be valid until the callback is called.
36 // The callback is called from the main cast thread as soon as 36 // 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 37 // the encoder is done with the frame; it does not mean that the encoded frame
38 // has been sent out. 38 // has been sent out.
39 virtual void InsertRawVideoFrame( 39 virtual void InsertRawVideoFrame(
40 const scoped_refptr<media::VideoFrame>& video_frame, 40 const scoped_refptr<media::VideoFrame>& video_frame,
41 const base::TimeTicks& capture_time) = 0; 41 const base::TimeTicks& capture_time) = 0;
42 42
43 // The |audio_bus| must be valid until the |done_callback| is called. 43 // 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 44 // 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 45 // done with |audio_bus|; it does not mean that the encoded data has been
46 // sent out. 46 // sent out.
47 virtual void InsertAudio(const AudioBus* audio_bus, 47 virtual void InsertAudio(const AudioBus* audio_bus,
48 const base::TimeTicks& recorded_time, 48 const base::TimeTicks& recorded_time,
49 const base::Closure& done_callback) = 0; 49 const base::Closure& done_callback) = 0;
50 50
51 // Set the audio sender on which audio frames will be inserted to Cast. Must
52 // be called on the main thread.
53 // This function MUST be called before raw frames are inserted.
54 virtual void SetAudioSender(base::WeakPtr<AudioSender> audio_sender) = 0;
55
56 // Set the video sender on which video frames will be inserted to Cast. Must
57 // be called on the main thread.
58 // This function must be called before raw frames are inserted.
59 virtual void SetVideoSender(base::WeakPtr<VideoSender> video_sender) = 0;
60
51 protected: 61 protected:
52 virtual ~FrameInput() {} 62 virtual ~FrameInput() {}
53 63
54 private: 64 private:
55 friend class base::RefCountedThreadSafe<FrameInput>; 65 friend class base::RefCountedThreadSafe<FrameInput>;
56 }; 66 };
57 67
58 // This Class is thread safe. 68 // This Class is thread safe.
59 // The provided CastTransportSender object will always be called from the main 69 // The provided CastTransportSender object will always be called from the main
60 // cast thread. 70 // cast thread.
61 // At least one of AudioSenderConfig and VideoSenderConfig have to be provided.
62 class CastSender { 71 class CastSender {
63 public: 72 public:
64 static CastSender* CreateCastSender( 73 static CastSender* Create(
Ami GONE FROM CHROMIUM 2014/02/14 18:23:54 I think you missed this comment: This doesn't doc
mikhal1 2014/02/18 19:20:43 Done, and matched receiver and transport. On 2014/
65 scoped_refptr<CastEnvironment> cast_environment, 74 scoped_refptr<CastEnvironment> cast_environment,
66 const AudioSenderConfig* audio_config, 75 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); 76 transport::CastTransportSender* const transport_sender);
71 77
72 virtual ~CastSender() {} 78 virtual ~CastSender() {}
73 79
74 // 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
75 // object. 81 // object.
76 // Can be called from any thread. 82 // Can be called from any thread.
77 virtual scoped_refptr<FrameInput> frame_input() = 0; 83 virtual scoped_refptr<FrameInput> frame_input() = 0;
78 84
79 // 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.
80 // Can be called from any thread. 86 // Can be called from any thread.
81 virtual transport::PacketReceiverCallback packet_receiver() = 0; 87 virtual transport::PacketReceiverCallback packet_receiver() = 0;
88
89 // Initialize the audio stack. Must be called in order to send audio frames.
90 // This function MUST be called before raw frames are inserted.
91 virtual void InitializeAudio(const AudioSenderConfig& audio_config) = 0;
92
93 // Initialize the video stack. Must be called in order to send video frames.
94 // This function must be called before raw frames are inserted.
95 virtual void InitializeVideo(
96 const VideoSenderConfig& video_config,
97 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories) = 0;
82 }; 98 };
83 99
84 } // namespace cast 100 } // namespace cast
85 } // namespace media 101 } // namespace media
86 102
87 #endif // MEDIA_CAST_CAST_SENDER_H_ 103 #endif // MEDIA_CAST_CAST_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698