2019-03-30 10:22:57 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-08-04 05:37:40 +00:00
|
|
|
#include "frame.hh"
|
|
|
|
#include "media.hh"
|
|
|
|
#include "queue.hh"
|
2019-03-30 10:22:57 +00:00
|
|
|
|
2020-04-27 11:07:24 +00:00
|
|
|
namespace uvg_rtp {
|
2019-05-22 09:43:35 +00:00
|
|
|
|
2020-08-04 05:37:40 +00:00
|
|
|
namespace formats {
|
2019-10-08 05:20:29 +00:00
|
|
|
|
2020-08-04 05:37:40 +00:00
|
|
|
struct hevc_headers {
|
2020-04-27 11:07:24 +00:00
|
|
|
uint8_t nal_header[uvg_rtp::frame::HEADER_SIZE_HEVC_NAL];
|
2019-10-08 05:20:29 +00:00
|
|
|
|
|
|
|
/* there are three types of Fragmentation Unit headers:
|
|
|
|
* - header for the first fragment
|
|
|
|
* - header for all middle fragments
|
|
|
|
* - header for the last fragment */
|
2020-04-27 11:07:24 +00:00
|
|
|
uint8_t fu_headers[3 * uvg_rtp::frame::HEADER_SIZE_HEVC_FU];
|
2020-08-04 05:37:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class hevc : public media {
|
|
|
|
public:
|
|
|
|
hevc(uvg_rtp::socket *socket, uvg_rtp::rtp *rtp, int flags);
|
|
|
|
~hevc();
|
|
|
|
|
|
|
|
/* Packet handler for RTP frames that transport HEVC bitstream
|
|
|
|
*
|
|
|
|
* Depending on what is received, packet handler will either merge
|
|
|
|
* TODO explain what it does on a high level
|
|
|
|
*
|
|
|
|
* Return RTP_OK if the packet was successfully handled
|
|
|
|
* Return RTP_PKT_READY if "out" contains an RTP that can be returned to user
|
|
|
|
* Return RTP_PKT_NOT_HANDLED if the packet is not handled by this handler
|
|
|
|
* Return RTP_PKT_MODIFIED if the packet was modified but should be forwarded to other handlers
|
|
|
|
* Return RTP_GENERIC_ERROR if the packet was corrupted in some way */
|
2020-08-10 05:58:23 +00:00
|
|
|
static rtp_error_t packet_handler(void *arg, int flags, frame::rtp_frame **frame);
|
2020-08-04 05:37:40 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
rtp_error_t __push_frame(uint8_t *data, size_t data_len, int flags);
|
|
|
|
|
|
|
|
private:
|
|
|
|
rtp_error_t push_hevc_frame(uint8_t *data, size_t data_len);
|
|
|
|
rtp_error_t push_hevc_nal(uint8_t *data, size_t data_len, bool more);
|
|
|
|
};
|
2019-05-22 09:43:35 +00:00
|
|
|
};
|
2019-03-30 10:22:57 +00:00
|
|
|
};
|