Go to the documentation of this file.
31 #define RTMP_DEFAULT_CHUNKSIZE 128
232 return (
p.buffer.get());
270 inline const std::uint8_t*
283 inline const std::uint8_t*
298 return p.bytesRead ==
p.header.dataSize;
343 bool connect(
const URL&
url);
368 void setBufferTime(
size_t time,
int streamID);
416 if (_messageQueue.empty())
return std::shared_ptr<SimpleBuffer>();
417 std::shared_ptr<SimpleBuffer>
b = _messageQueue.front();
418 _messageQueue.pop_front();
428 if (_flvQueue.empty())
return std::shared_ptr<SimpleBuffer>();
429 std::shared_ptr<SimpleBuffer>
b = _flvQueue.front();
430 _flvQueue.pop_front();
438 int readSocket(std::uint8_t* dst,
int num);
447 _serverBandwidth = bw;
452 return _serverBandwidth;
484 bool hasPacket(ChannelType
t,
size_t channel)
const;
490 RTMPPacket& getPacket(ChannelType
t,
size_t channel);
505 typedef std::map<size_t, RTMPPacket> ChannelSet;
510 ChannelSet _inChannels;
513 ChannelSet _outChannels;
515 std::deque<std::shared_ptr<SimpleBuffer> > _messageQueue;
516 std::deque<std::shared_ptr<SimpleBuffer> > _flvQueue;
519 std::uint32_t _serverBandwidth;
522 std::uint32_t _bandwidth;
525 size_t _outChunkSize;
527 std::unique_ptr<HandShaker> _handShaker;
537 std::unique_ptr<RTMPPacket> _incompletePacket;
std::uint32_t bandwidth() const
Get our bandwidth.
Definition: RTMP.h:461
@ CONTROL_PONG
Definition: RTMP.h:77
@ CONTROL_CLEAR_BUFFER
Definition: RTMP.h:72
@ PACKET_TYPE_SHARED_OBJECT
Definition: RTMP.h:124
int _inChunkSize
Definition: RTMP.h:465
void update()
This function handles reading incoming data and filling data queues.
Definition: RTMP.cpp:231
size_t _bytesInSent
Definition: RTMP.h:469
@ RTMP_PACKET_SIZE_MINIMUM
Definition: RTMP.h:148
void play(const SimpleBuffer &amf, int id)
This is used for sending NetStream requests.
Definition: RTMP.cpp:385
bool sendPacket(RTMPPacket &packet)
Send an RTMPPacket on the connection.
Definition: RTMP.cpp:582
@ CONTROL_REQUEST_VERIFY
Definition: RTMP.h:78
std::uint8_t m_nClientBW2
Definition: RTMP.h:467
void appendNetworkLong(const std::uint32_t l)
Append 4 bytes to the buffer.
Definition: SimpleBuffer.h:169
@ CONTROL_BUFFER_TIME
Definition: RTMP.h:74
void log_debug(StringType msg, Args... args)
Definition: log.h:301
@ i
Definition: GnashKey.h:155
#define LOG_ONCE(x)
Definition: log.h:49
@ CONTROL_BUFFER_EMPTY
Definition: RTMP.h:80
void setBufferTime(size_t time, int streamID)
Instruct server to buffer this much data.
Definition: RTMP.cpp:183
bool isReady(const RTMPPacket &p)
Check if a packet is ready for processing.
Definition: RTMP.h:297
@ PACKET_TYPE_AUDIO
Definition: RTMP.h:118
#define _(String)
Definition: log.h:44
size_t _bytesIn
Definition: RTMP.h:468
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
size_t payloadSize(const RTMPPacket &p)
The current size of the space allocated for the message payload.
Definition: RTMP.h:252
@ PACKET_TYPE_METADATA
Definition: RTMP.h:123
~RTMPPacket()
Definition: RTMP.h:211
bool sendServerBW(RTMP &r)
Send the server bandwidth.
Definition: RTMP.cpp:402
@ s
Definition: GnashKey.h:165
An RTMPPacket class contains a full description of an RTMP packet.
Definition: RTMP.h:195
virtual bool eof() const
Return true if the end of the stream has been reached.
Definition: Socket.cpp:415
@ n
Definition: GnashKey.h:160
@ RTMP_PACKET_SIZE_LARGE
Definition: RTMP.h:145
std::uint16_t readNetworkShort(const std::uint8_t *buf)
Read an unsigned 16-bit value in network byte order.
Definition: AMF.h:119
#define __FUNCTION__
Definition: log.h:437
@ CONTROL_CLEAR_STREAM
Definition: RTMP.h:71
bool connected() const
Whether a connection attempt is complete.
Definition: Socket.cpp:50
const std::uint8_t * payloadEnd(const RTMPPacket &p)
Get the end of the allocated payload data section of the buffer.
Definition: RTMP.h:284
@ PACKET_TYPE_CONTROL
Definition: RTMP.h:115
void log_error(StringType msg, Args... args)
Definition: log.h:283
@ PACKET_TYPE_FLEX_STREAM_SEND
Definition: RTMP.h:120
@ PACKET_TYPE_CLIENTBW
Definition: RTMP.h:117
Channels
The known channels.
Definition: RTMP.h:103
void setServerBandwidth(std::uint32_t bw)
Store the server bandwidth.
Definition: RTMP.h:446
std::shared_ptr< SimpleBuffer > buffer
A buffer with enough storage to write the entire message.
Definition: RTMP.h:219
std::uint32_t readNetworkLong(const std::uint8_t *buf)
Read an unsigned 32-bit value in network byte order.
Definition: AMF.h:129
@ PACKET_TYPE_FLEX_MESSAGE
Definition: RTMP.h:122
@ t
Definition: GnashKey.h:166
@ PACKET_TYPE_FLV
Definition: RTMP.h:126
@ r
Definition: GnashKey.h:164
bool error() const
Whether the RTMP connection is in error condition.
Definition: RTMP.h:385
PacketSize
The PacketSize specifies the number of fields contained in the header.
Definition: RTMP.h:144
ControlType
Known control / ping codes.
Definition: RTMP.h:70
RTMPHeader header
Definition: RTMP.h:213
std::string readString(const std::uint8_t *&pos, const std::uint8_t *end)
Read a string value from the buffer.
Definition: AMF.cpp:87
@ play
Definition: klash_part.cpp:330
size_t size() const
Return size of the buffer.
Definition: SimpleBuffer.h:75
std::uint8_t * data()
Get a pointer to start of data. May be NULL if size==0.
Definition: SimpleBuffer.h:81
A simple IOChannel subclass for reading and writing sockets.
Definition: Socket.h:42
@ p
Definition: GnashKey.h:162
std::shared_ptr< SimpleBuffer > getFLVFrame()
Get an FLV packet received from the server.
Definition: RTMP.h:427
@ CHANNEL_CONTROL1
Definition: RTMP.h:104
@ PACKET_TYPE_INVOKE
Definition: RTMP.h:125
void clearPayload(RTMPPacket &p)
Clear the message body and the bytes read of an RTMPPacket.
Definition: RTMP.h:241
virtual std::streamsize read(void *dst, std::streamsize num)
Read exactly the given number of bytes from the Socket or none at all.
Definition: Socket.cpp:302
bool connect(const URL &url)
Initiate a network connection.
Definition: RTMP.cpp:200
@ PACKET_TYPE_NONE
Definition: RTMP.h:112
virtual std::streamsize write(const void *src, std::streamsize num)
Write the given number of bytes to the stream.
Definition: Socket.cpp:355
@ CONTROL_BUFFER_READY
Definition: RTMP.h:81
This class is for handling the RTMP protocol.
Definition: RTMP.h:327
@ CONTROL_RESET_STREAM
Definition: RTMP.h:75
bool sendCtrl(RTMP &r, ControlType t, unsigned int nObject, unsigned int nTime)
Send a control packet.
Definition: RTMP.cpp:964
@ RTMP_PACKET_SIZE_SMALL
Definition: RTMP.h:147
void close()
Close the connection.
Definition: RTMP.cpp:785
@ CHANNEL_VIDEO
Definition: RTMP.h:106
size_t bytesRead
Definition: RTMP.h:221
void close()
Close the Socket.
Definition: Socket.cpp:114
std::string url
Definition: gnash.cpp:59
std::shared_ptr< SimpleBuffer > getMessage()
Get an AMF message received from the server.
Definition: RTMP.h:415
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
void call(const SimpleBuffer &amf)
This is used for sending call requests from the core.
Definition: RTMP.cpp:189
#define RTMP_DEFAULT_CHUNKSIZE
Definition: RTMP.h:31
@ CHANNEL_CONTROL2
Definition: RTMP.h:105
std::ostream & operator<<(std::ostream &o, PacketType p)
Logging assistance for PacketType.
Definition: RTMP.cpp:1180
@ PACKET_TYPE_CHUNK_SIZE
Definition: RTMP.h:113
@ c
Definition: GnashKey.h:149
int readSocket(std::uint8_t *dst, int num)
Read from the socket.
Definition: RTMP.cpp:359
@ PACKET_TYPE_FLEX_SHARED_OBJECT
Definition: RTMP.h:121
bool hasPayload(const RTMPPacket &p)
Check whether an RTMPPacket has a payload.
Definition: RTMP.h:230
~RTMP()
Definition: RTMP.cpp:155
@ PACKET_TYPE_BYTES_READ
Definition: RTMP.h:114
#define DSOEXPORT
Definition: dsodefs.h:55
@ STRING_AMF0
Definition: AMF.h:49
bool equal(string_table &st, string_table::key a, string_table::key b, bool caseless)
Check whether two keys are equivalent.
Definition: string_table.cpp:174
@ PACKET_TYPE_SERVERBW
Definition: RTMP.h:116
RTMPPacket(size_t reserve=0)
Construct a packet with an optional reserved memory allocation.
Definition: RTMP.cpp:121
bool connect(const std::string &hostname, std::uint16_t port)
Initiate a connection.
Definition: Socket.cpp:147
@ RTMP_PACKET_SIZE_MEDIUM
Definition: RTMP.h:146
@ PACKET_TYPE_VIDEO
Definition: RTMP.h:119
Uniform Resource Locator.
Definition: URL.h:35
RTMP()
Construct a non-connected RTMP handler.
Definition: RTMP.cpp:140
@ o
Definition: GnashKey.h:161
bool connected() const
Whether we have a basic connection to a server.
Definition: RTMP.h:378
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
std::string hexify(const unsigned char *p, size_t length, bool ascii)
Convert a sequence of bytes to hex or ascii format.
Definition: log.cpp:48
int m_mediaChannel
Definition: RTMP.h:466
@ CONTROL_PING
Definition: RTMP.h:76
PacketType
The known packet types.
Definition: RTMP.h:111
void appendNetworkShort(const std::uint16_t s)
Append 2 bytes to the buffer.
Definition: SimpleBuffer.h:154
@ b
Definition: GnashKey.h:148
@ CONTROL_RESPOND_VERIFY
Definition: RTMP.h:79
virtual bool bad() const
True if the Socket is in an error condition.
Definition: Socket.h:79
@ CONTROL_STREAM_DRY
Definition: RTMP.h:73
void handlePacket(const RTMPPacket &packet)
Handle an RTMPPacket.
Definition: RTMP.cpp:285
std::uint32_t serverBandwidth() const
Get the stored server bandwidth.
Definition: RTMP.h:451
std::uint8_t * payloadData(RTMPPacket &p)
Access the payload data section of the buffer.
Definition: RTMP.h:262
A simple buffer of bytes.
Definition: SimpleBuffer.h:38
void setBandwidth(std::uint32_t bw)
Store our bandwidth.
Definition: RTMP.h:456