forked from paullouisageneau/libdatachannel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack.cpp
73 lines (50 loc) · 2.16 KB
/
track.cpp
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
/**
* Copyright (c) 2020-2021 Paul-Louis Ageneau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "track.hpp"
#include "impl/internals.hpp"
#include "impl/track.hpp"
namespace rtc {
Track::Track(impl_ptr<impl::Track> impl)
: CheshireCat<impl::Track>(impl), Channel(std::dynamic_pointer_cast<impl::Channel>(impl)) {}
Track::~Track() {}
string Track::mid() const { return impl()->mid(); }
Description::Direction Track::direction() const { return impl()->direction(); }
Description::Media Track::description() const { return impl()->description(); }
void Track::setDescription(Description::Media description) {
impl()->setDescription(std::move(description));
}
void Track::close() { impl()->close(); }
bool Track::send(message_variant data) { return impl()->outgoing(make_message(std::move(data))); }
bool Track::send(const byte *data, size_t size) { return send(binary(data, data + size)); }
bool Track::isOpen(void) const { return impl()->isOpen(); }
bool Track::isClosed(void) const { return impl()->isClosed(); }
size_t Track::maxMessageSize() const { return impl()->maxMessageSize(); }
void Track::setMediaHandler(shared_ptr<MediaHandler> handler) {
impl()->setMediaHandler(std::move(handler));
}
void Track::chainMediaHandler(shared_ptr<MediaHandler> handler) {
if (auto first = impl()->getMediaHandler())
first->addToChain(std::move(handler));
else
impl()->setMediaHandler(std::move(handler));
}
bool Track::requestKeyframe() {
// only push PLI for video
if (description().type() == "video")
if (auto handler = impl()->getMediaHandler())
return handler->requestKeyframe([this](message_ptr m) { impl()->transportSend(m); });
return false;
}
bool Track::requestBitrate(unsigned int bitrate) {
if (auto handler = impl()->getMediaHandler())
return handler->requestBitrate(bitrate,
[this](message_ptr m) { impl()->transportSend(m); });
return false;
}
shared_ptr<MediaHandler> Track::getMediaHandler() { return impl()->getMediaHandler(); }
} // namespace rtc