blob: 254370b3639612190a5c201788743f56ec633212 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This is the main interface for the cast sender. All configuration are done
// at creation.
//
// The FrameInput and PacketReciever interfaces should normally be accessed from
// the IO thread. However they are allowed to be called from any thread.
#ifndef MEDIA_CAST_CAST_SENDER_H_
#define MEDIA_CAST_CAST_SENDER_H_
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "media/cast/cast_config.h"
#include "media/cast/cast_thread.h"
namespace media {
namespace cast {
// This Class is thread safe.
class FrameInput {
public:
// The video_frame must be valid until the callback is called.
// The callback is called from the main cast thread as soon as
// the encoder is done with the frame; it does not mean that the encoded frame
// has been sent out.
virtual void InsertRawVideoFrame(const I420VideoFrame* video_frame,
const base::TimeTicks& capture_time,
const base::Closure callback) = 0;
// The video_frame must be valid until the callback is called.
// The callback is called from the main cast thread as soon as
// the cast sender is done with the frame; it does not mean that the encoded
// frame has been sent out.
virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame,
const base::TimeTicks& capture_time,
const base::Closure callback) = 0;
// The audio_frame must be valid until the callback is called.
// The callback is called from the main cast thread as soon as
// the encoder is done with the frame; it does not mean that the encoded frame
// has been sent out.
virtual void InsertRawAudioFrame(const PcmAudioFrame* audio_frame,
const base::TimeTicks& recorded_time,
const base::Closure callback) = 0;
// The audio_frame must be valid until the callback is called.
// The callback is called from the main cast thread as soon as
// the cast sender is done with the frame; it does not mean that the encoded
// frame has been sent out.
virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame,
const base::TimeTicks& recorded_time,
const base::Closure callback) = 0;
protected:
virtual ~FrameInput() {}
};
// This Class is thread safe.
class CastSender {
public:
static CastSender* CreateCastSender(
scoped_refptr<CastThread> cast_thread,
const AudioSenderConfig& audio_config,
const VideoSenderConfig& video_config,
VideoEncoderController* const video_encoder_controller,
PacketSender* const packet_sender);
virtual ~CastSender() {};
// All audio and video frames for the session should be inserted to this
// object.
// Can be called from any thread.
virtual scoped_refptr<FrameInput> frame_input() = 0;
// All RTCP packets for the session should be inserted to this object.
// Can be called from any thread.
virtual scoped_refptr<PacketReceiver> packet_receiver() = 0;
};
} // namespace cast
} // namespace media
#endif // MEDIA_CAST_CAST_SENDER_H_
|