Merge remote-tracking branch 'qatar/master'

* qatar/master:
  movenc: Don't write the 'wave' atom or its child 'enda' for lpcm audio.
  imc: some cosmetics
  rtmp: Pass the proper return code in rtmp_handshake
  rtmp: Check return codes of net IO operations

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/59/head n0.12-dev
Michael Niedermayer 13 years ago
commit c0b47d1914
  1. 111
      libavcodec/imc.c
  2. 2
      libavformat/movenc.c
  3. 15
      libavformat/rtmppkt.c
  4. 98
      libavformat/rtmpproto.c

@ -99,7 +99,8 @@ static VLC huffman_vlc[4][4];
static const int vlc_offsets[17] = {
0, 640, 1156, 1732, 2308, 2852, 3396, 3924,
4452, 5220, 5860, 6628, 7268, 7908, 8424, 8936, VLC_TABLES_SIZE};
4452, 5220, 5860, 6628, 7268, 7908, 8424, 8936, VLC_TABLES_SIZE
};
static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2];
@ -130,13 +131,10 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI);
r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI);
if (i & 0x1)
{
if (i & 0x1) {
q->pre_coef1[i] = (r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = -(r1 - r2) * sqrt(2.0);
}
else
{
} else {
q->pre_coef1[i] = -(r1 + r2) * sqrt(2.0);
q->pre_coef2[i] = (r1 - r2) * sqrt(2.0);
}
@ -146,9 +144,8 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
/* Generate a square root table */
for(i = 0; i < 30; i++) {
for (i = 0; i < 30; i++)
q->sqrt_tab[i] = sqrt(i);
}
/* initialize the VLC tables */
for (i = 0; i < 4 ; i++) {
@ -176,7 +173,8 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
return 0;
}
static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeffs2, int* bandWidthT,
static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1,
float *flcoeffs2, int *bandWidthT,
float *flcoeffs3, float *flcoeffs5)
{
float workT1[BANDS];
@ -230,7 +228,8 @@ static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeff
}
static void imc_read_level_coeffs(IMCContext* q, int stream_format_code, int* levlCoeffs)
static void imc_read_level_coeffs(IMCContext *q, int stream_format_code,
int *levlCoeffs)
{
int i;
VLC *hufftab[4];
@ -250,14 +249,15 @@ static void imc_read_level_coeffs(IMCContext* q, int stream_format_code, int* le
if (start)
levlCoeffs[0] = get_bits(&q->gb, 7);
for (i = start; i < BANDS; i++) {
levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table, hufftab[cb_sel[i]]->bits, 2);
levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table,
hufftab[cb_sel[i]]->bits, 2);
if (levlCoeffs[i] == 17)
levlCoeffs[i] += get_bits(&q->gb, 4);
}
}
static void imc_decode_level_coefficients(IMCContext* q, int* levlCoeffBuf, float* flcoeffs1,
float* flcoeffs2)
static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf,
float *flcoeffs1, float *flcoeffs2)
{
int i, level;
float tmp, tmp2;
@ -290,12 +290,15 @@ static void imc_decode_level_coefficients(IMCContext* q, int* levlCoeffBuf, floa
}
static void imc_decode_level_coefficients2(IMCContext* q, int* levlCoeffBuf, float* old_floor, float* flcoeffs1,
float* flcoeffs2) {
static void imc_decode_level_coefficients2(IMCContext *q, int *levlCoeffBuf,
float *old_floor, float *flcoeffs1,
float *flcoeffs2)
{
int i;
//FIXME maybe flag_buf = noise coding and flcoeffs1 = new scale factors
// and flcoeffs2 old scale factors
// might be incomplete due to a missing table that is in the binary code
/* FIXME maybe flag_buf = noise coding and flcoeffs1 = new scale factors
* and flcoeffs2 old scale factors
* might be incomplete due to a missing table that is in the binary code
*/
for (i = 0; i < BANDS; i++) {
flcoeffs1[i] = 0;
if (levlCoeffBuf[i] < 16) {
@ -310,7 +313,9 @@ static void imc_decode_level_coefficients2(IMCContext* q, int* levlCoeffBuf, flo
/**
* Perform bit allocation depending on bits available
*/
static int bit_allocation (IMCContext* q, int stream_format_code, int freebits, int flag) {
static int bit_allocation(IMCContext *q, int stream_format_code, int freebits,
int flag)
{
int i, j;
const float limit = -1.e20;
float highest = 0.0;
@ -330,9 +335,8 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
for (i = 0; i < BANDS; i++)
highest = FFMAX(highest, q->flcoeffs1[i]);
for(i = 0; i < BANDS-1; i++) {
for (i = 0; i < BANDS - 1; i++)
q->flcoeffs4[i] = q->flcoeffs3[i] - log(q->flcoeffs5[i]) / log(2);
}
q->flcoeffs4[BANDS - 1] = limit;
highest = highest * 0.25;
@ -351,7 +355,7 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
if (indx == -1)
return AVERROR_INVALIDDATA;
q->flcoeffs4[i] = q->flcoeffs4[i] + xTab[(indx*2 + (q->flcoeffs1[i] < highest)) * 2 + flag];
q->flcoeffs4[i] += xTab[(indx * 2 + (q->flcoeffs1[i] < highest)) * 2 + flag];
}
if (stream_format_code & 0x2) {
@ -371,7 +375,8 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
for (i = 0; i < BANDS / 2; i++) {
rres = summer - freebits;
if((rres >= -8) && (rres <= 8)) break;
if ((rres >= -8) && (rres <= 8))
break;
summer = 0;
iacc = 0;
@ -405,7 +410,8 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
if (freebits > summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20 : (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20
: (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
}
highest = 0.0;
@ -426,7 +432,7 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
if (highest > -1.e20) {
workT[found_indx] -= 2.0;
if (++(q->bitsBandT[found_indx]) == 6)
if (++q->bitsBandT[found_indx] == 6)
workT[found_indx] = -1.e20;
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
@ -438,7 +444,8 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
}
if (freebits < summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = q->bitsBandT[i] ? (q->bitsBandT[i] * -2 + q->flcoeffs4[i] + 1.585) : 1.e20;
workT[i] = q->bitsBandT[i] ? (q->bitsBandT[i] * -2 + q->flcoeffs4[i] + 1.585)
: 1.e20;
}
if (stream_format_code & 0x2) {
workT[0] = 1.e20;
@ -455,10 +462,11 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
low_indx = i;
}
}
//if(lowest >= 1.e10) break;
// if (lowest >= 1.e10)
// break;
workT[low_indx] = lowest + 2.0;
if (!(--q->bitsBandT[low_indx]))
if (!--q->bitsBandT[low_indx])
workT[low_indx] = 1.e20;
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
@ -472,7 +480,8 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
return 0;
}
static void imc_get_skip_coeff(IMCContext* q) {
static void imc_get_skip_coeff(IMCContext *q)
{
int i, j;
memset(q->skipFlagBits, 0, sizeof(q->skipFlagBits));
@ -485,11 +494,12 @@ static void imc_get_skip_coeff(IMCContext* q) {
q->skipFlagBits[i] = band_tab[i + 1] - band_tab[i];
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
if ((q->skipFlags[j] = get_bits1(&q->gb)))
q->skipFlags[j] = get_bits1(&q->gb);
if (q->skipFlags[j])
q->skipFlagCount[i]++;
}
} else {
for(j = band_tab[i]; j < (band_tab[i+1]-1); j += 2) {
for (j = band_tab[i]; j < band_tab[i + 1] - 1; j += 2) {
if (!get_bits1(&q->gb)) { // 0
q->skipFlagBits[i]++;
q->skipFlags[j] = 1;
@ -526,7 +536,8 @@ static void imc_get_skip_coeff(IMCContext* q) {
/**
* Increase highest' band coefficient sizes as some bits won't be used
*/
static void imc_adjust_bit_allocation (IMCContext* q, int summer) {
static void imc_adjust_bit_allocation(IMCContext *q, int summer)
{
float workT[32];
int corrected = 0;
int i, j;
@ -534,7 +545,8 @@ static void imc_adjust_bit_allocation (IMCContext* q, int summer) {
int found_indx = 0;
for (i = 0; i < BANDS; i++) {
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20 : (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
workT[i] = (q->bitsBandT[i] == 6) ? -1.e20
: (q->bitsBandT[i] * -2 + q->flcoeffs4[i] - 0.415);
}
while (corrected < summer) {
@ -565,7 +577,8 @@ static void imc_adjust_bit_allocation (IMCContext* q, int summer) {
}
}
static void imc_imdct256(IMCContext *q) {
static void imc_imdct256(IMCContext *q)
{
int i;
float re, im;
@ -585,13 +598,16 @@ static void imc_imdct256(IMCContext *q) {
for (i = 0; i < COEFFS / 2; i++) {
re = ( q->samples[i].re * q->post_cos[i]) + (-q->samples[i].im * q->post_sin[i]);
im = (-q->samples[i].im * q->post_cos[i]) - ( q->samples[i].re * q->post_sin[i]);
q->out_samples[i*2] = (q->mdct_sine_window[COEFFS-1-i*2] * q->last_fft_im[i]) + (q->mdct_sine_window[i*2] * re);
q->out_samples[COEFFS-1-i*2] = (q->mdct_sine_window[i*2] * q->last_fft_im[i]) - (q->mdct_sine_window[COEFFS-1-i*2] * re);
q->out_samples[i * 2] = (q->mdct_sine_window[COEFFS - 1 - i * 2] * q->last_fft_im[i])
+ (q->mdct_sine_window[i * 2] * re);
q->out_samples[COEFFS - 1 - i * 2] = (q->mdct_sine_window[i * 2] * q->last_fft_im[i])
- (q->mdct_sine_window[COEFFS - 1 - i * 2] * re);
q->last_fft_im[i] = im;
}
}
static int inverse_quant_coeff (IMCContext* q, int stream_format_code) {
static int inverse_quant_coeff(IMCContext *q, int stream_format_code)
{
int i, j;
int middle_value, cw_len, max_size;
const float *quantizer;
@ -629,11 +645,13 @@ static int inverse_quant_coeff (IMCContext* q, int stream_format_code) {
}
static int imc_get_coeffs (IMCContext* q) {
static int imc_get_coeffs(IMCContext *q)
{
int i, j, cw_len, cw;
for (i = 0; i < BANDS; i++) {
if(!q->sumLenArr[i]) continue;
if (!q->sumLenArr[i])
continue;
if (q->bandFlagsBuf[i] || q->bandWidthT[i]) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
cw_len = q->CWlengthT[j];
@ -707,8 +725,10 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
if (q->decoder_reset) {
memset(q->out_samples, 0, sizeof(q->out_samples));
for(i = 0; i < BANDS; i++)q->old_floor[i] = 1.0;
for(i = 0; i < COEFFS; i++)q->CWdecoded[i] = 0;
for (i = 0; i < BANDS; i++)
q->old_floor[i] = 1.0;
for (i = 0; i < COEFFS; i++)
q->CWdecoded[i] = 0;
q->decoder_reset = 0;
}
@ -716,9 +736,11 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
imc_read_level_coeffs(q, stream_format_code, q->levlCoeffBuf);
if (stream_format_code & 0x4)
imc_decode_level_coefficients(q, q->levlCoeffBuf, q->flcoeffs1, q->flcoeffs2);
imc_decode_level_coefficients(q, q->levlCoeffBuf,
q->flcoeffs1, q->flcoeffs2);
else
imc_decode_level_coefficients2(q, q->levlCoeffBuf, q->old_floor, q->flcoeffs1, q->flcoeffs2);
imc_decode_level_coefficients2(q, q->levlCoeffBuf, q->old_floor,
q->flcoeffs1, q->flcoeffs2);
memcpy(q->old_floor, q->flcoeffs1, 32 * sizeof(float));
@ -758,7 +780,8 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,
}
if ((ret = bit_allocation(q, stream_format_code,
512 - bitscount - get_bits_count(&q->gb), flag)) < 0) {
512 - bitscount - get_bits_count(&q->gb),
flag)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n");
q->decoder_reset = 1;
return ret;

@ -680,7 +680,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
track->enc->codec_id == CODEC_ID_ALAC ||
track->enc->codec_id == CODEC_ID_ADPCM_MS ||
track->enc->codec_id == CODEC_ID_ADPCM_IMA_WAV ||
mov_pcm_le_gt16(track->enc->codec_id)))
(mov_pcm_le_gt16(track->enc->codec_id) && version==1)))
mov_write_wave_tag(pb, track);
else if(track->tag == MKTAG('m','p','4','a'))
mov_write_esds_tag(pb, track);

@ -151,7 +151,10 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
offset += chunk_size;
size += chunk_size;
if (data_size > 0) {
ffurl_read_complete(h, &t, 1); //marker
if ((ret = ffurl_read_complete(h, &t, 1)) < 0) { // marker
ff_rtmp_packet_destroy(p);
return ret;
}
size++;
if (t != (0xC0 + channel_id))
return -1;
@ -167,6 +170,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
int mode = RTMP_PS_TWELVEBYTES;
int off = 0;
int size = 0;
int ret;
pkt->ts_delta = pkt->timestamp - prev_pkt[pkt->channel_id].timestamp;
@ -218,15 +222,18 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
}
prev_pkt[pkt->channel_id].extra = pkt->extra;
ffurl_write(h, pkt_hdr, p-pkt_hdr);
if ((ret = ffurl_write(h, pkt_hdr, p - pkt_hdr)) < 0)
return ret;
size = p - pkt_hdr + pkt->data_size;
while (off < pkt->data_size) {
int towrite = FFMIN(chunk_size, pkt->data_size - off);
ffurl_write(h, pkt->data + off, towrite);
if ((ret = ffurl_write(h, pkt->data + off, towrite)) < 0)
return ret;
off += towrite;
if (off < pkt->data_size) {
uint8_t marker = 0xC0 | pkt->channel_id;
ffurl_write(h, &marker, 1);
if ((ret = ffurl_write(h, &marker, 1)) < 0)
return ret;
size++;
}
}

@ -167,10 +167,11 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
pkt.data_size = p - pkt.data;
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -194,10 +195,11 @@ static int gen_release_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_string(&p, rt->playpath);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -221,10 +223,11 @@ static int gen_fcpublish_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_string(&p, rt->playpath);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -248,10 +251,11 @@ static int gen_fcunpublish_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_string(&p, rt->playpath);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -276,10 +280,11 @@ static int gen_create_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
rt->create_stream_invoke = rt->nb_invokes;
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
@ -305,10 +310,11 @@ static int gen_delete_stream(URLContext *s, RTMPContext *rt)
ff_amf_write_null(&p);
ff_amf_write_number(&p, rt->main_channel_id);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -336,9 +342,13 @@ static int gen_play(URLContext *s, RTMPContext *rt)
ff_amf_write_string(&p, rt->playpath);
ff_amf_write_number(&p, rt->live);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
if (ret < 0)
return ret;
// set client buffer time disguised in ping packet
if ((ret = ff_rtmp_packet_create(&pkt, RTMP_NETWORK_CHANNEL, RTMP_PT_PING,
1, 10)) < 0)
@ -349,10 +359,11 @@ static int gen_play(URLContext *s, RTMPContext *rt)
bytestream_put_be32(&p, 1);
bytestream_put_be32(&p, 256); //TODO: what is a good value here?
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -379,7 +390,8 @@ static int gen_publish(URLContext *s, RTMPContext *rt)
ff_amf_write_string(&p, rt->playpath);
ff_amf_write_string(&p, "live");
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
@ -401,10 +413,11 @@ static int gen_pong(URLContext *s, RTMPContext *rt, RTMPPacket *ppkt)
p = pkt.data;
bytestream_put_be16(&p, 7);
bytestream_put_be32(&p, AV_RB32(ppkt->data+2));
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -422,10 +435,11 @@ static int gen_server_bw(URLContext *s, RTMPContext *rt)
p = pkt.data;
bytestream_put_be32(&p, 2500000);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
/**
@ -446,7 +460,8 @@ static int gen_check_bw(URLContext *s, RTMPContext *rt)
ff_amf_write_number(&p, ++rt->nb_invokes);
ff_amf_write_null(&p);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
@ -467,10 +482,11 @@ static int gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts)
p = pkt.data;
bytestream_put_be32(&p, rt->bytes_read);
ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return 0;
return ret;
}
//TODO: Move HMAC code somewhere. Eventually.
@ -617,16 +633,22 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
if (client_pos < 0)
return client_pos;
ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE + 1);
i = ffurl_read_complete(rt->stream, serverdata, RTMP_HANDSHAKE_PACKET_SIZE + 1);
if (i != RTMP_HANDSHAKE_PACKET_SIZE + 1) {
if ((ret = ffurl_write(rt->stream, tosend,
RTMP_HANDSHAKE_PACKET_SIZE + 1)) < 0) {
av_log(s, AV_LOG_ERROR, "Cannot write RTMP handshake request\n");
return ret;
}
if ((ret = ffurl_read_complete(rt->stream, serverdata,
RTMP_HANDSHAKE_PACKET_SIZE + 1)) < 0) {
av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n");
return AVERROR(EIO);
return ret;
}
i = ffurl_read_complete(rt->stream, clientdata, RTMP_HANDSHAKE_PACKET_SIZE);
if (i != RTMP_HANDSHAKE_PACKET_SIZE) {
if ((ret = ffurl_read_complete(rt->stream, clientdata,
RTMP_HANDSHAKE_PACKET_SIZE)) < 0) {
av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n");
return AVERROR(EIO);
return ret;
}
av_log(s, AV_LOG_DEBUG, "Server version %d.%d.%d.%d\n",
@ -678,9 +700,13 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
return ret;
// write reply back to the server
ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE);
if ((ret = ffurl_write(rt->stream, tosend,
RTMP_HANDSHAKE_PACKET_SIZE)) < 0)
return ret;
} else {
ffurl_write(rt->stream, serverdata+1, RTMP_HANDSHAKE_PACKET_SIZE);
if ((ret = ffurl_write(rt->stream, serverdata + 1,
RTMP_HANDSHAKE_PACKET_SIZE)) < 0)
return ret;
}
return 0;
@ -710,7 +736,9 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
return -1;
}
if (!rt->is_input)
ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size, rt->prev_pkt[1]);
if ((ret = ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size,
rt->prev_pkt[1])) < 0)
return ret;
rt->chunk_size = AV_RB32(pkt->data);
if (rt->chunk_size <= 0) {
av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size);
@ -1201,7 +1229,9 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
if (rt->flv_off == rt->flv_size) {
rt->skip_bytes = 4;
ff_rtmp_packet_write(rt->stream, &rt->out_pkt, rt->chunk_size, rt->prev_pkt[1]);
if ((ret = ff_rtmp_packet_write(rt->stream, &rt->out_pkt,
rt->chunk_size, rt->prev_pkt[1])) < 0)
return ret;
ff_rtmp_packet_destroy(&rt->out_pkt);
rt->flv_size = 0;
rt->flv_off = 0;

Loading…
Cancel
Save