Skip to content

Commit

Permalink
obs-outputs: Add video_id_t value for 0
Browse files Browse the repository at this point in the history
This will be initialized to 0 in various cases, so let's make that
a valid enum value (even if it's not valid in rtmp?)
  • Loading branch information
palana authored and RytoEX committed May 3, 2024
1 parent fab8f0f commit 64caf04
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/obs-outputs/flv-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ enum datatype_t {
static void s_w4cc(struct serializer *s, enum video_id_t id)
{
switch (id) {
case CODEC_NONE:
assert(0 && "Tried to serialize CODEC_NONE");
break;

case CODEC_AV1:
s_w8(s, 'a');
s_w8(s, 'v');
Expand Down
1 change: 1 addition & 0 deletions plugins/obs-outputs/flv-mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define MILLISECOND_DEN 1000

enum video_id_t {
CODEC_NONE = 0, // not valid in rtmp
CODEC_H264 = 1, // legacy & Y2023 spec
CODEC_AV1, // Y2023 spec
CODEC_HEVC,
Expand Down
11 changes: 11 additions & 0 deletions plugins/obs-outputs/flv-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ static bool write_video_header(struct flv_output *stream, size_t idx)
return false;

switch (stream->video_codec[idx]) {
case CODEC_NONE:
do_log(LOG_ERROR,
"Codec not initialized for track %zu while sending header",
idx);
return false;

case CODEC_H264:
packet.size = obs_parse_avc_header(&packet.data, header, size);
// Always send H.264 on track 0 as old style for compatibility.
Expand Down Expand Up @@ -541,6 +547,11 @@ static void flv_output_data(void *data, struct encoder_packet *packet)
}

switch (stream->video_codec[packet->track_idx]) {
case CODEC_NONE:
do_log(LOG_ERROR, "Codec not initialized for track %zu",
packet->track_idx);
goto unlock;

case CODEC_H264:
obs_parse_avc_packet(&parsed_packet, packet);
break;
Expand Down
11 changes: 11 additions & 0 deletions plugins/obs-outputs/rtmp-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,12 @@ static bool send_video_header(struct rtmp_stream *stream, size_t idx)
return false;

switch (stream->video_codec[idx]) {
case CODEC_NONE:
do_log(LOG_ERROR,
"Codec not initialized for track %zu while sending header",
idx);
return false;

case CODEC_H264:
packet.size = obs_parse_avc_header(&packet.data, header, size);
// Always send H.264 on track 0 as old style for compatibility.
Expand Down Expand Up @@ -1747,6 +1753,11 @@ static void rtmp_stream_data(void *data, struct encoder_packet *packet)
}

switch (stream->video_codec[packet->track_idx]) {
case CODEC_NONE:
do_log(LOG_ERROR, "Codec not initialized for track %zu",
packet->track_idx);
return;

case CODEC_H264:
obs_parse_avc_packet(&new_packet, packet);
break;
Expand Down

0 comments on commit 64caf04

Please sign in to comment.