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.
5 // This is the main interface for the cast sender. All configuration are done
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"
21 #include "media/cast/transport/cast_transport_sender.h"
22 #include "media/filters/gpu_video_accelerator_factories.h"
32 // This Class is thread safe.
33 class FrameInput : public base::RefCountedThreadSafe<FrameInput> {
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
37 // the encoder is done with the frame; it does not mean that the encoded frame
39 virtual void InsertRawVideoFrame(
40 const scoped_refptr<media::VideoFrame>& video_frame,
41 const base::TimeTicks& capture_time) = 0;
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
45 // done with |audio_bus|; it does not mean that the encoded data has been
47 virtual void InsertAudio(const AudioBus* audio_bus,
48 const base::TimeTicks& recorded_time,
49 const base::Closure& done_callback) = 0;
52 virtual ~FrameInput() {}
55 friend class base::RefCountedThreadSafe<FrameInput>;
58 // This Class is thread safe.
59 // The provided PacketSender object will always be called form the main cast
63 static CastSender* CreateCastSender(
64 scoped_refptr<CastEnvironment> cast_environment,
65 const AudioSenderConfig& audio_config,
66 const VideoSenderConfig& video_config,
67 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
68 transport::CastTransportSender* const transport_sender);
69 // TODO(pwestin): Add callback for status messages; initialized, errors etc.
71 virtual ~CastSender() {}
73 // All audio and video frames for the session should be inserted to this
75 // Can be called from any thread.
76 virtual scoped_refptr<FrameInput> frame_input() = 0;
78 // All RTCP packets for the session should be inserted to this object.
79 // Can be called from any thread.
80 virtual scoped_refptr<transport::PacketReceiver> packet_receiver() = 0;
86 #endif // MEDIA_CAST_CAST_SENDER_H_