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

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: rebase Created 6 years, 9 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
« no previous file with comments | « media/cast/cast_receiver_impl.cc ('k') | media/cast/cast_sender_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 main thread.
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 // The provided CastTransportSender and the CastSender should be called from the
59 // The provided CastTransportSender object will always be called from the main 67 // main thread.
60 // cast thread.
61 // 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 scoped_ptr<CastSender> Create(
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,
70 transport::CastTransportSender* const transport_sender); 72 transport::CastTransportSender* const transport_sender);
71 73
72 virtual ~CastSender() {} 74 virtual ~CastSender() {}
73 75
74 // All audio and video frames for the session should be inserted to this 76 // All video frames for the session should be inserted to this object.
75 // object. 77 virtual scoped_refptr<VideoFrameInput> video_frame_input() = 0;
76 // Can be called from any thread. 78
77 virtual scoped_refptr<FrameInput> frame_input() = 0; 79 // All audio frames for the session should be inserted to this object.
80 virtual scoped_refptr<AudioFrameInput> audio_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 // This function and the callback must be called on the main 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 // Status of the initialization will be returned on cast_initialization_cb.
88 virtual void InitializeAudio(
89 const AudioSenderConfig& audio_config,
90 const CastInitializationCallback& cast_initialization_cb) = 0;
91
92 // Initialize the video stack. Must be called in order to send video frames.
93 // Status of the initialization will be returned on cast_initialization_cb.
94 virtual void InitializeVideo(
95 const VideoSenderConfig& video_config,
96 const CastInitializationCallback& cast_initialization_cb,
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
« no previous file with comments | « media/cast/cast_receiver_impl.cc ('k') | media/cast/cast_sender_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698