forked from maaron/rtp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.h
64 lines (48 loc) · 1.89 KB
/
stream.h
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
#pragma once
#include "rtp_service.h"
#include "rtcp.h"
#include <boost\asio.hpp>
#include <boost\thread.hpp>
namespace media
{
using namespace boost::asio;
class rtp_packet;
class rtcp_packet;
class stream
{
rtp_service connections;
uint32_t ssrc;
rtcp rtcp;
bool init;
uint32_t remote_start_time;
void start_rtp_receive();
void start_rtcp_receive();
void start_rtcp_timer();
// This method performs the media loop-back by taking a received
// packet, modifying header fields and sending it to the RTP peer.
void loop_rtp_packet(rtp_packet&);
// This is called whenever an RTP packet is received.
void rtp_received(rtp_packet&);
// This is called whenever an RTCP packet is received.
void rtcp_received(rtcp_packet&);
public:
stream(boost::asio::io_service&, const char* cname);
~stream();
// Opens RTP and RTCP sockets for a single stream
void open(const ip::address& iface, int& rtp_port, int& rtcp_port);
// Starts send/receive operations on all streams. Any calls to
// open() must be made prior to calling this method.
void start(const ip::udp::endpoint rtp_peer, const ip::udp::endpoint rtcp_peer);
// Same as above, but doesn't send anything until something is
// received from a remote peer (in order to determine the remote
// address/port). This is particularly useful for loopback.
void start();
// Schedules an RTCP BYE message to be sent. The message won't
// necessarily be sent upon return of this method, as it occurrs in
// the context of another thread.
void bye();
// Stops the stream by completing/canceling any outstanding
// operations, closing sockets, etc.
void stop();
};
}