Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add support for slice segments" #21

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions include/smolrtsp/nal_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ typedef struct {
* The maximum size of an H.265 NAL unit (including the header).
*/
size_t max_h265_nalu_size;

/**
* The encoder uses slice segments.
*/
bool is_coded_slice;
} SmolRTSP_NalTransportConfig;

/**
Expand All @@ -56,7 +51,6 @@ typedef struct {
*
* - `max_h264_nalu_size` is #SMOLRTSP_MAX_H264_NALU_SIZE.
* - `max_h265_nalu_size` is #SMOLRTSP_MAX_H265_NALU_SIZE.
* - `is_coded_slice` is `false`.
*/
SmolRTSP_NalTransportConfig
SmolRTSP_NalTransportConfig_default(void) SMOLRTSP_PRIV_MUST_USE;
Expand Down
10 changes: 4 additions & 6 deletions src/nal_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

static int send_fragmentized_nal_data(
SmolRTSP_RtpTransport *t, SmolRTSP_RtpTimestamp ts, size_t max_packet_size,
SmolRTSP_NalUnit nalu, bool is_coded_slice);
SmolRTSP_NalUnit nalu);
static int send_fu(
SmolRTSP_RtpTransport *t, SmolRTSP_RtpTimestamp ts, SmolRTSP_NalUnit fu,
bool is_first_fragment, bool is_last_fragment);
Expand All @@ -19,7 +19,6 @@ SmolRTSP_NalTransportConfig SmolRTSP_NalTransportConfig_default(void) {
return (SmolRTSP_NalTransportConfig){
.max_h264_nalu_size = SMOLRTSP_MAX_H264_NALU_SIZE,
.max_h265_nalu_size = SMOLRTSP_MAX_H265_NALU_SIZE,
.is_coded_slice = false,
};
}

Expand Down Expand Up @@ -89,15 +88,14 @@ int SmolRTSP_NalTransport_send_packet(
}

return send_fragmentized_nal_data(
self->transport, ts, max_packet_size, nalu,
self->config.is_coded_slice);
self->transport, ts, max_packet_size, nalu);
}

// See <https://tools.ietf.org/html/rfc6184#section-5.8> (H.264),
// <https://tools.ietf.org/html/rfc7798#section-4.4.3> (H.265).
static int send_fragmentized_nal_data(
SmolRTSP_RtpTransport *t, SmolRTSP_RtpTimestamp ts, size_t max_packet_size,
SmolRTSP_NalUnit nalu, bool is_coded_slice) {
SmolRTSP_NalUnit nalu) {
const size_t rem = nalu.payload.len % max_packet_size,
packets_count = (nalu.payload.len - rem) / max_packet_size;

Expand All @@ -122,7 +120,7 @@ static int send_fragmentized_nal_data(
U8Slice99_advance(nalu.payload, packets_count * max_packet_size);
const SmolRTSP_NalUnit fu = {nalu.header, fu_data};
const bool is_first_fragment = 0 == packets_count,
is_last_fragment = !is_coded_slice;
is_last_fragment = true;

if (send_fu(t, ts, fu, is_first_fragment, is_last_fragment) == -1) {
return -1;
Expand Down