Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / cast / cast_sender.h
blob9dfe4ad72a925a95d3fc7f5d8043cbe2010ed1ca
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. All configuration are done
6 // at creation.
7 //
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.
11 #ifndef MEDIA_CAST_CAST_SENDER_H_
12 #define MEDIA_CAST_CAST_SENDER_H_
14 #include "base/basictypes.h"
15 #include "base/callback.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/time/tick_clock.h"
18 #include "base/time/time.h"
19 #include "media/cast/cast_config.h"
20 #include "media/cast/cast_environment.h"
22 namespace media {
23 namespace cast {
25 // This Class is thread safe.
26 class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
27 public:
28 // The video_frame must be valid until the callback is called.
29 // The callback is called from the main cast thread as soon as
30 // the encoder is done with the frame; it does not mean that the encoded frame
31 // has been sent out.
32 virtual void InsertRawVideoFrame(const I420VideoFrame* video_frame,
33 const base::TimeTicks& capture_time,
34 const base::Closure callback) = 0;
36 // The video_frame must be valid until the callback is called.
37 // The callback is called from the main cast thread as soon as
38 // the cast sender is done with the frame; it does not mean that the encoded
39 // frame has been sent out.
40 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame,
41 const base::TimeTicks& capture_time,
42 const base::Closure callback) = 0;
44 // The audio_frame must be valid until the callback is called.
45 // The callback is called from the main cast thread as soon as
46 // the encoder is done with the frame; it does not mean that the encoded frame
47 // has been sent out.
48 virtual void InsertRawAudioFrame(const PcmAudioFrame* audio_frame,
49 const base::TimeTicks& recorded_time,
50 const base::Closure callback) = 0;
52 // The audio_frame must be valid until the callback is called.
53 // The callback is called from the main cast thread as soon as
54 // the cast sender is done with the frame; it does not mean that the encoded
55 // frame has been sent out.
56 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame,
57 const base::TimeTicks& recorded_time,
58 const base::Closure callback) = 0;
60 static void DeleteAudioFrame(const PcmAudioFrame* frame);
62 static void DeleteVideoFrame(const I420VideoFrame* video_frame);
64 protected:
65 virtual ~FrameInput() {}
67 private:
68 friend class base::RefCountedThreadSafe<FrameInput>;
71 // This Class is thread safe.
72 // The provided PacketSender object will always be called form the main cast
73 // thread.
74 class CastSender {
75 public:
76 static CastSender* CreateCastSender(
77 scoped_refptr<CastEnvironment> cast_environment,
78 const AudioSenderConfig& audio_config,
79 const VideoSenderConfig& video_config,
80 VideoEncoderController* const video_encoder_controller,
81 PacketSender* const packet_sender);
83 virtual ~CastSender() {}
85 // All audio and video frames for the session should be inserted to this
86 // object.
87 // Can be called from any thread.
88 virtual scoped_refptr<FrameInput> frame_input() = 0;
90 // All RTCP packets for the session should be inserted to this object.
91 // Can be called from any thread.
92 virtual scoped_refptr<PacketReceiver> packet_receiver() = 0;
95 } // namespace cast
96 } // namespace media
98 #endif // MEDIA_CAST_CAST_SENDER_H_