avformat/mmst: add logging context to log

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
pull/323/head
Steven Liu 5 years ago
parent 4ff97342ce
commit cdf8253a06
  1. 40
      libavformat/mmst.c

@ -141,7 +141,7 @@ static int send_command_packet(MMSTContext *mmst)
// write it out.
write_result= ffurl_write(mms->mms_hd, mms->out_buffer, exact_length);
if(write_result != exact_length) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Failed to write data of length %d: %d (%s)\n",
exact_length, write_result,
write_result < 0 ? strerror(AVUNERROR(write_result)) :
@ -215,11 +215,11 @@ static int send_media_file_request(MMSTContext *mmst)
static void handle_packet_stream_changing_type(MMSTContext *mmst)
{
MMSContext *mms = &mmst->mms;
av_log(NULL, AV_LOG_TRACE, "Stream changing!\n");
av_log(mms->mms_hd, AV_LOG_TRACE, "Stream changing!\n");
// 40 is the packet header size, 7 is the prefix size.
mmst->header_packet_id= AV_RL32(mms->in_buffer + 40 + 7);
av_log(NULL, AV_LOG_TRACE, "Changed header prefix to 0x%x", mmst->header_packet_id);
av_log(mms->mms_hd, AV_LOG_TRACE, "Changed header prefix to 0x%x", mmst->header_packet_id);
}
static int send_keepalive_packet(MMSTContext *mmst)
@ -251,12 +251,12 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
read_result = ffurl_read_complete(mms->mms_hd, mms->in_buffer, 8);
if (read_result != 8) {
if(read_result < 0) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Error reading packet header: %d (%s)\n",
read_result, strerror(AVUNERROR(read_result)));
packet_type = SC_PKT_CANCEL;
} else {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"The server closed the connection\n");
packet_type = SC_PKT_NO_DATA;
}
@ -270,7 +270,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
mmst->incoming_flags= mms->in_buffer[3];
read_result= ffurl_read_complete(mms->mms_hd, mms->in_buffer+8, 4);
if(read_result != 4) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Reading command packet length failed: %d (%s)\n",
read_result,
read_result < 0 ? strerror(AVUNERROR(read_result)) :
@ -279,11 +279,11 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
}
length_remaining= AV_RL32(mms->in_buffer+8) + 4;
av_log(NULL, AV_LOG_TRACE, "Length remaining is %d\n", length_remaining);
av_log(mms->mms_hd, AV_LOG_TRACE, "Length remaining is %d\n", length_remaining);
// read the rest of the packet.
if (length_remaining < 0
|| length_remaining > sizeof(mms->in_buffer) - 12) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Incoming packet length %d exceeds bufsize %"SIZE_SPECIFIER"\n",
length_remaining, sizeof(mms->in_buffer) - 12);
return AVERROR_INVALIDDATA;
@ -291,7 +291,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
read_result = ffurl_read_complete(mms->mms_hd, mms->in_buffer + 12,
length_remaining) ;
if (read_result != length_remaining) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Reading pkt data (length=%d) failed: %d (%s)\n",
length_remaining, read_result,
read_result < 0 ? strerror(AVUNERROR(read_result)) :
@ -300,7 +300,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
}
packet_type= AV_RL16(mms->in_buffer+36);
if (read_result >= 44 && (hr = AV_RL32(mms->in_buffer + 40))) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Server sent a message with packet type 0x%x and error status code 0x%08x\n", packet_type, hr);
return AVERROR(EINVAL);
}
@ -319,7 +319,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
if (length_remaining < 0
|| length_remaining > sizeof(mms->in_buffer) - 8) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Data length %d is invalid or too large (max=%"SIZE_SPECIFIER")\n",
length_remaining, sizeof(mms->in_buffer));
return AVERROR_INVALIDDATA;
@ -328,7 +328,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
mms->read_in_ptr = mms->in_buffer;
read_result= ffurl_read_complete(mms->mms_hd, mms->in_buffer, length_remaining);
if(read_result != length_remaining) {
av_log(NULL, AV_LOG_ERROR,
av_log(mms->mms_hd, AV_LOG_ERROR,
"Failed to read packet data of size %d: %d (%s)\n",
length_remaining, read_result,
read_result < 0 ? strerror(AVUNERROR(read_result)) :
@ -358,7 +358,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
} else if(packet_id_type == mmst->packet_id) {
packet_type = SC_PKT_ASF_MEDIA;
} else {
av_log(NULL, AV_LOG_TRACE, "packet id type %d is old.", packet_id_type);
av_log(mms->mms_hd, AV_LOG_TRACE, "packet id type %d is old.", packet_id_type);
continue;
}
}
@ -555,14 +555,14 @@ static int mms_open(URLContext *h, const char *uri, int flags)
if (err)
goto fail;
if((mmst->incoming_flags != 0X08) && (mmst->incoming_flags != 0X0C)) {
av_log(NULL, AV_LOG_ERROR,
av_log(h, AV_LOG_ERROR,
"The server does not support MMST (try MMSH or RTSP)\n");
err = AVERROR(EINVAL);
goto fail;
}
err = ff_mms_asf_header_parser(mms);
if (err) {
av_log(NULL, AV_LOG_TRACE, "asf header parsed failed!\n");
av_log(h, AV_LOG_TRACE, "asf header parsed failed!\n");
goto fail;
}
mms->header_parsed = 1;
@ -579,11 +579,11 @@ static int mms_open(URLContext *h, const char *uri, int flags)
if (err) {
goto fail;
}
av_log(NULL, AV_LOG_TRACE, "Leaving open (success)\n");
av_log(h, AV_LOG_TRACE, "Leaving open (success)\n");
return 0;
fail:
mms_close(h);
av_log(NULL, AV_LOG_TRACE, "Leaving open (failure: %d)\n", err);
av_log(mms->mms_hd, AV_LOG_TRACE, "Leaving open (failure: %d)\n", err);
return err;
}
@ -608,7 +608,7 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
int err = mms_safe_send_recv(mmst, NULL, SC_PKT_ASF_MEDIA);
if (err == 0) {
if(mms->remaining_in_len>mms->asf_packet_len) {
av_log(NULL, AV_LOG_ERROR,
av_log(h, AV_LOG_ERROR,
"Incoming pktlen %d is larger than ASF pktsize %d\n",
mms->remaining_in_len, mms->asf_packet_len);
result= AVERROR(EIO);
@ -616,12 +616,12 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
// copy the data to the packet buffer.
result = ff_mms_read_data(mms, buf, size);
if (result == 0) {
av_log(NULL, AV_LOG_TRACE, "Read ASF media packet size is zero!\n");
av_log(h, AV_LOG_TRACE, "Read ASF media packet size is zero!\n");
break;
}
}
} else {
av_log(NULL, AV_LOG_TRACE, "read packet error!\n");
av_log(h, AV_LOG_TRACE, "read packet error!\n");
break;
}
}

Loading…
Cancel
Save