Keep track of sample rate and channel configuration in each packet
This commit is contained in:
parent
78832faacd
commit
93affec3ea
4 changed files with 26 additions and 13 deletions
19
src/main.c
19
src/main.c
|
@ -666,3 +666,22 @@ get_device_connection(const char *dev)
|
|||
return speed >= 480 ? HOSTCONNECTION_USB480 : HOSTCONNECTION_USB12;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static const int sample_rates[16] = {
|
||||
96000, 88200, 64000, 48000, 44100, 32000,
|
||||
24000, 22050, 16000, 12000, 11025, 8000, 7350
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int
|
||||
sri_to_rate(int sri)
|
||||
{
|
||||
return sample_rates[sri & 0xf];
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ typedef struct th_pkt {
|
|||
uint8_t pkt_frametype;
|
||||
uint8_t pkt_field; // Set if packet is only a half frame (a field)
|
||||
|
||||
uint8_t pkt_channels;
|
||||
uint8_t pkt_sri;
|
||||
|
||||
uint8_t *pkt_payload;
|
||||
int pkt_payloadlen;
|
||||
|
||||
|
|
|
@ -35,11 +35,6 @@
|
|||
#include "parser_latm.h"
|
||||
#include "bitstream.h"
|
||||
|
||||
static const int mpeg4audio_sample_rates[16] = {
|
||||
96000, 88200, 64000, 48000, 44100, 32000,
|
||||
24000, 22050, 16000, 12000, 11025, 8000, 7350
|
||||
};
|
||||
|
||||
|
||||
typedef struct latm_private {
|
||||
|
||||
|
@ -54,12 +49,6 @@ typedef struct latm_private {
|
|||
|
||||
|
||||
|
||||
static int aac_sample_rates[16] = {
|
||||
96000, 88200, 64000, 48000, 44100, 32000,
|
||||
24000, 22050, 16000, 12000, 11025, 8000, 7350
|
||||
};
|
||||
|
||||
|
||||
static uint32_t
|
||||
latm_get_value(bitstream_t *bs)
|
||||
{
|
||||
|
@ -82,7 +71,7 @@ read_audio_specific_config(th_stream_t *st, latm_private_t *latm,
|
|||
if(latm->sample_rate_index == 0xf)
|
||||
return;
|
||||
|
||||
sr = aac_sample_rates[latm->sample_rate_index];
|
||||
sr = sri_to_rate(latm->sample_rate_index);
|
||||
st->st_frame_duration = 1024 * 90000 / sr;
|
||||
|
||||
latm->channel_config = read_bits(bs, 4);
|
||||
|
@ -211,6 +200,8 @@ parse_latm_audio_mux_element(th_transport_t *t, th_stream_t *st, uint8_t *data,
|
|||
pkt->pkt_payloadlen = slot_len + 7;
|
||||
pkt->pkt_payload = malloc(pkt->pkt_payloadlen);
|
||||
pkt->pkt_duration = st->st_frame_duration;
|
||||
pkt->pkt_sri = latm->sample_rate_index;
|
||||
pkt->pkt_channels = latm->channel_config;
|
||||
|
||||
/* 7 bytes of ADTS header */
|
||||
init_bits(&out, pkt->pkt_payload, 56);
|
||||
|
|
|
@ -810,7 +810,7 @@ getmonoclock(void)
|
|||
return tp.tv_sec * 1000000ULL + (tp.tv_nsec / 1000);
|
||||
}
|
||||
|
||||
|
||||
int sri_to_rate(int sri);
|
||||
|
||||
|
||||
extern time_t dispatch_clock;
|
||||
|
|
Loading…
Add table
Reference in a new issue