UMA: Improve description of Enterprise.EnrollmentRecovery histogram.
[chromium-blink-merge.git] / media / cast / cast_sender.h
blobc9bad7aa1eb747af480edbca92d8e80c936ab62e
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
3 // found in the LICENSE file.
4 //
5 // This is the main interface for the cast sender.
6 //
7 // The AudioFrameInput, VideoFrameInput and PacketReciever interfaces should
8 // be accessed from the main thread.
10 #ifndef MEDIA_CAST_CAST_SENDER_H_
11 #define MEDIA_CAST_CAST_SENDER_H_
13 #include "base/basictypes.h"
14 #include "base/callback.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/time/tick_clock.h"
18 #include "base/time/time.h"
19 #include "media/base/audio_bus.h"
20 #include "media/cast/cast_config.h"
21 #include "media/cast/cast_environment.h"
22 #include "media/cast/net/cast_transport_sender.h"
24 namespace media {
25 class VideoFrame;
27 namespace cast {
28 class AudioSender;
29 class VideoSender;
31 class VideoFrameInput : public base::RefCountedThreadSafe<VideoFrameInput> {
32 public:
33 // Insert video frames into Cast sender. Frames will be encoded, packetized
34 // and sent to the network.
35 virtual void InsertRawVideoFrame(
36 const scoped_refptr<media::VideoFrame>& video_frame,
37 const base::TimeTicks& capture_time) = 0;
39 protected:
40 virtual ~VideoFrameInput() {}
42 private:
43 friend class base::RefCountedThreadSafe<VideoFrameInput>;
46 class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> {
47 public:
48 // Insert audio frames into Cast sender. Frames will be encoded, packetized
49 // and sent to the network.
50 virtual void InsertAudio(scoped_ptr<AudioBus> audio_bus,
51 const base::TimeTicks& recorded_time) = 0;
53 protected:
54 virtual ~AudioFrameInput() {}
56 private:
57 friend class base::RefCountedThreadSafe<AudioFrameInput>;
60 // All methods of CastSender must be called on the main thread.
61 // Provided CastTransportSender will also be called on the main thread.
62 class CastSender {
63 public:
64 static scoped_ptr<CastSender> Create(
65 scoped_refptr<CastEnvironment> cast_environment,
66 CastTransportSender* const transport_sender);
68 virtual ~CastSender() {}
70 // All video frames for the session should be inserted to this object.
71 virtual scoped_refptr<VideoFrameInput> video_frame_input() = 0;
73 // All audio frames for the session should be inserted to this object.
74 virtual scoped_refptr<AudioFrameInput> audio_frame_input() = 0;
76 // Initialize the audio stack. Must be called in order to send audio frames.
77 // Status of the initialization will be returned on cast_initialization_cb.
78 virtual void InitializeAudio(
79 const AudioSenderConfig& audio_config,
80 const CastInitializationCallback& cast_initialization_cb) = 0;
82 // Initialize the video stack. Must be called in order to send video frames.
83 // Status of the initialization will be returned on cast_initialization_cb.
84 virtual void InitializeVideo(
85 const VideoSenderConfig& video_config,
86 const CastInitializationCallback& cast_initialization_cb,
87 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
88 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb) = 0;
91 } // namespace cast
92 } // namespace media
94 #endif // MEDIA_CAST_CAST_SENDER_H_