Skip to content

Commit

Permalink
fix time skew in payload type/sample rate fields in status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ka9q committed May 5, 2024
1 parent e14b628 commit d2d8efa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
6 changes: 0 additions & 6 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ int send_output(struct channel * restrict const chan,float const * restrict buff
if(frames <= 0 || chan->output.channels == 0 || chan->output.samprate == 0)
return 0;

int const type = pt_from_info(chan->output.samprate,chan->output.channels); // It might have changed
if(type < 0)
return 0; // Can't allocate a payload type!

chan->output.rtp.type = type;

if(mute){
// Increment timestamp
chan->output.rtp.timestamp += frames; // Increase by frame count
Expand Down
10 changes: 1 addition & 9 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,7 @@ static int loadconfig(char const * const file){
strlcpy(chan->output.dest_string,data,sizeof(chan->output.dest_string));
memcpy(&chan->status.dest_socket,&metadata_dest_socket,sizeof(chan->status.dest_socket));

// Set RTP payload type from static table specific to ka9q-radio
// Should assign dynamically, but requires completion of SDP
int const type = pt_from_info(chan->output.samprate,chan->output.channels);
if(type < 0){
fprintf(stdout,"can't allocate RTP payload type for samprate %'d, channels %d\n",chan->output.samprate,chan->output.channels);
close_chan(chan); // OK to call here outside demod, since it's not running yet
continue;
}
chan->output.rtp.type = type;
chan->output.rtp.type = pt_from_info(chan->output.samprate,chan->output.channels);
chan->status.output_interval = update;

// Time to start it -- ssrc is stashed by create_chan()
Expand Down
16 changes: 4 additions & 12 deletions radio_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ bool decode_radio_commands(struct channel *chan,uint8_t const *buffer,int length
int const new_sample_rate = decode_int(cp,optlen);
if(new_sample_rate != chan->output.samprate){
chan->output.samprate = new_sample_rate;
chan->output.rtp.type = pt_from_info(chan->output.samprate,chan->output.channels);
restart_needed = true;
}
}
Expand Down Expand Up @@ -341,8 +342,10 @@ bool decode_radio_commands(struct channel *chan,uint8_t const *buffer,int length
case OUTPUT_CHANNELS: // int
{
int const i = decode_int(cp,optlen);
if(i == 1 || i == 2)
if(i != chan->output.channels && (i == 1 || i == 2)){
chan->output.channels = i;
chan->output.rtp.type = pt_from_info(chan->output.samprate,chan->output.channels);
}
}
break;
case SQUELCH_OPEN:
Expand Down Expand Up @@ -388,17 +391,6 @@ bool decode_radio_commands(struct channel *chan,uint8_t const *buffer,int length
chan->status.output_interval = x;
}
break;
case RTP_PT:
// Also sent in RTP data streams; sent explictly here to link with OUTPUT_SAMPRATE and OUTPUT_CHANNELS in receiver table
{
int const x = decode_int(cp,optlen);
if(x >=0 && x < 128)
chan->output.rtp.type = x;
}
break;
case OUTPUT_ENCODING:
chan->output.encoding = decode_int(cp,optlen);
break;
default:
break;
}
Expand Down

0 comments on commit d2d8efa

Please sign in to comment.