Skip to content

Commit

Permalink
Code format with LOGX
Browse files Browse the repository at this point in the history
  • Loading branch information
dengxiayehu committed Jan 9, 2017
1 parent f57ac98 commit fc257ac
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 160 deletions.
30 changes: 10 additions & 20 deletions src/xutil/xamf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ int get_amf_obj_end(const byte *&p, uint32_t len)
return 0;
}

int get_amf_associate_array(const byte *&p, uint32_t len,
AMFAssociateArray &amfasoarr)
int get_amf_associate_array(const byte *&p, uint32_t len, AMFAssociateArray &amfasoarr)
{
const byte *savep = p;

Expand Down Expand Up @@ -376,28 +375,23 @@ void print_amf_list(const char *indent, struct list_head *head)
list_for_each_entry_safe(amfobj, x, head, list) {
switch (amfobj->typ) {
case AMF_TYPE_NUMBER:
printf("%s%.2lf\n", indent,
int2double(amfobj->amfnum.val));
printf("%s%.2lf\n", indent, int2double(amfobj->amfnum.val));
break;

case AMF_TYPE_BOOL:
printf("%s%s\n", indent,
amfobj->amfbool.b ? "true" : "false");
printf("%s%s\n", indent, amfobj->amfbool.b ? "true" : "false");
break;

case AMF_TYPE_STRING:
printf("%s%-24s\n", indent,
amfobj->amfstr.str);
printf("%s%-24s\n", indent, amfobj->amfstr.str);
break;

case AMF_TYPE_OBJECT:
printf("%sTYPE_OBJECT {\n", indent);
if (amfobj->amftypobj.arr) { // In case it NULL
FOR_VECTOR_ITERATOR(ArrayItem *, *amfobj->amftypobj.arr, it) {
printf("%s%-24s : ", indent,
(*it)->first->amfstr.str);
print_amf_list(sprintf_("%s\t", indent).c_str(),
&(*it)->second);
printf("%s%-24s : ", indent, (*it)->first->amfstr.str);
print_amf_list(sprintf_("%s\t", indent).c_str(), &(*it)->second);
}
}
printf("%s}\n", indent);
Expand All @@ -407,10 +401,8 @@ void print_amf_list(const char *indent, struct list_head *head)
printf("%sASSOCIATE_ARRAY {\n", indent);
if (amfobj->amfasoarr.arr) { // In case it NULL
FOR_VECTOR_ITERATOR(ArrayItem *, *amfobj->amfasoarr.arr, it) {
printf("%s%-24s : ", indent,
(*it)->first->amfstr.str);
print_amf_list(sprintf_("%s\t", indent).c_str(),
&(*it)->second);
printf("%s%-24s : ", indent, (*it)->first->amfstr.str);
print_amf_list(sprintf_("%s\t", indent).c_str(), &(*it)->second);
}
}
printf("%s}\n", indent);
Expand Down Expand Up @@ -488,8 +480,7 @@ int put_amf_obj_end(byte *&p)
return 0;
}

int put_amf_associate_array(byte *&p,
const AMFAssociateArray &amfasoarr)
int put_amf_associate_array(byte *&p, const AMFAssociateArray &amfasoarr)
{
byte *savep = p;

Expand Down Expand Up @@ -628,8 +619,7 @@ int strm_amf_list(byte *&p, struct list_head *head)
break;

default:
LOGW("Not supported amfobj(%d) to stream",
amfobj->typ);
LOGW("Not supported amfobj(%d) to stream", amfobj->typ);
break;
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/xutil/xamf.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ int parse_amf(const byte *&buff, uint32_t len, struct list_head *head);
int get_amf_string(const byte *&p, uint32_t len, AMFString &amfstr);
int get_amf_number(const byte *&p, uint32_t len, AMFNumber &amfnum);
int get_amf_bool(const byte *&p, uint32_t len, AMFNumber &amfbool);
int get_amf_associate_array(const byte *&p, uint32_t len,
AMFAssociateArray &amfasoarr);
int get_amf_associate_array(const byte *&p, uint32_t len, AMFAssociateArray &amfasoarr);
int get_amf_array(const byte *&p, uint32_t len, AMFArray &amfarr);
int get_amf_typobj(const byte *&p, uint32_t len, AMFObject &amftypobj);
int get_amf_date(const byte *&p, uint32_t len, AMFDate &amfdate);
Expand All @@ -100,8 +99,7 @@ int put_amf_string(byte *&p, const char *str);
int put_amf_number(byte *&p, double val);
int put_amf_bool(byte *&p, bool b);
int put_amf_obj_end(byte *&p);
int put_amf_associate_array(byte *&p,
const AMFAssociateArray &amfasoarr);
int put_amf_associate_array(byte *&p, const AMFAssociateArray &amfasoarr);
int put_amf_typobj(byte *&p, const AMFObject &amftypobj);
int put_amf_array(byte *&p, const AMFArray &amfarr);

Expand Down
21 changes: 7 additions & 14 deletions src/xutil/xcurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ int CurlImpl::glob_info::perform()
mc = curl_multi_perform(multi, &still_running);
} while (mc == CURLM_CALL_MULTI_PERFORM);
if (mc != CURLM_OK) {
LOGE("curl_multi_perform() failed:%s",
curl_multi_strerror(mc));
LOGE("curl_multi_perform() failed:%s", curl_multi_strerror(mc));
goto bail;
}

Expand Down Expand Up @@ -245,8 +244,7 @@ int CurlImpl::glob_info::perform()
mc = curl_multi_perform(multi, &still_running);
} while (mc == CURLM_CALL_MULTI_PERFORM);
if (mc != CURLM_OK) {
LOGE("curl_multi_perform() failed:%s",
curl_multi_strerror(mc));
LOGE("curl_multi_perform() failed:%s", curl_multi_strerror(mc));
goto bail;
}
break;
Expand Down Expand Up @@ -285,8 +283,7 @@ int CurlImpl::glob_info::perform()
while (!connvec.empty())
delete (connvec[0]);
} else {
LOGE("multi(%p) has remaining easy handle(#%d)",
multi, transfers);
LOGE("multi(%p) has remaining easy handle(#%d)", multi, transfers);
goto bail;
}
END
Expand Down Expand Up @@ -396,8 +393,7 @@ int CurlImpl::conn_info::setup(Curl::request *req_, glob_info *glob_)
}
CURLMcode mc = curl_multi_add_handle(glob_->multi, easy);
if (mc != CURLM_OK) {
LOGE("curl_multi_add_handle(%p) failed: %s",
easy, curl_multi_strerror(mc));
LOGE("curl_multi_add_handle(%p) failed: %s", easy, curl_multi_strerror(mc));
goto bail;
}
glob = glob_;
Expand All @@ -417,8 +413,7 @@ int CurlImpl::conn_info::perform()
{
CURLcode res = curl_easy_perform(easy);
if (res != CURLE_OK) {
LOGE("curl_easy_perform() failed: %s",
curl_easy_strerror(res));
LOGE("curl_easy_perform() failed: %s", curl_easy_strerror(res));
cleanup();
return -1;
}
Expand Down Expand Up @@ -500,8 +495,7 @@ void CurlImpl::conn_info::dump(const char *text, uint8_t *ptr, size_t size, char
if (nohex)
width = 0x40;

iobuf->read_from_string("\n%s, %10.10ld bytes (0x%8.8lx)\n",
text, (long) size, (long) size);
iobuf->read_from_string("\n%s, %10.10ld bytes (0x%8.8lx)\n", text, (long) size, (long) size);

for (size_t i = 0; i < size; i += width) {
iobuf->read_from_string("%4.4lx: ", (long) i);
Expand All @@ -520,8 +514,7 @@ void CurlImpl::conn_info::dump(const char *text, uint8_t *ptr, size_t size, char
i += (c+2-width);
break;
}
iobuf->read_from_string("%c",
(ptr[i+c]>=0x20)&&(ptr[i+c]<0x80)?ptr[i+c]:'.');
iobuf->read_from_string("%c", (ptr[i+c]>=0x20)&&(ptr[i+c]<0x80)?ptr[i+c]:'.');
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i += (c+3-width);
break;
Expand Down
73 changes: 22 additions & 51 deletions src/xutil/xffmpeg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ void priv_set_pts_info(Stream *s, int pts_wrap_bits,
unsigned int pts_num, unsigned int pts_den)
{
if (pts_num <= 0 || pts_den <= 0) {
LOGE("Ignoring attempt to set invalid timebase %d/%d for st:%d",
pts_num, pts_den, s->index);
LOGE("Ignoring attempt to set invalid timebase %d/%d for st:%d", pts_num, pts_den, s->index);
return;
}
s->time_base.num = pts_num;
Expand Down Expand Up @@ -732,10 +731,8 @@ int combine_frame(ParseContext *pc, int next,
{
if (pc->overread) {
#ifdef DEBUG
LOGD("overread %d, state:%X next:%d index:%d o_index:%d",
pc->overread, pc->state, next, pc->index, pc->overread_index);
LOGD("%X %X %X %X",
(*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
LOGD("overread %d, state:%X next:%d index:%d o_index:%d", pc->overread, pc->state, next, pc->index, pc->overread_index);
LOGD("%X %X %X %X", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
#endif
}

Expand Down Expand Up @@ -794,10 +791,8 @@ int combine_frame(ParseContext *pc, int next,

if (pc->overread) {
#ifdef DEBUG
LOGD("overread %d, state:%X next:%d index:%d o_index:%d",
pc->overread, pc->state, next, pc->index, pc->overread_index);
LOGD("%X %X %X %X",
(*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
LOGD("overread %d, state:%X next:%d index:%d o_index:%d", pc->overread, pc->state, next, pc->index, pc->overread_index);
LOGD("%X %X %X %X", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
#endif
}

Expand Down Expand Up @@ -978,8 +973,7 @@ uint8_t *h264_decode_nal(H264Context *h, const uint8_t *src,
uint8_t *p = (uint8_t *) realloc(h->rbsp_buffer[bufidx],
wanted_size);
if (!p) {
LOGE("realloc for rbsp_buffer[%d] failed: %s",
bufidx, ERRNOMSG);
LOGE("realloc for rbsp_buffer[%d] failed: %s", bufidx, ERRNOMSG);
return NULL;
}
memset(p, 0, wanted_size);
Expand Down Expand Up @@ -1147,13 +1141,11 @@ void estimate_timings(FormatContext *ic, off_t old_offset)
Stream *st = ic->streams[i];
UNUSED(st);
#ifdef DEBUG
LOGD("%d: start_time: %lf", i,
(double) st->start_time / AV_TIME_BASE);
LOGD("%d: start_time: %lf", i, (double) st->start_time / AV_TIME_BASE);
#endif
}
#ifdef DEBUG
LOGD("stream: start_time: %lf",
(double) ic->start_time / AV_TIME_BASE);
LOGD("stream: start_time: %lf", (double) ic->start_time / AV_TIME_BASE);
#endif
}

Expand Down Expand Up @@ -1265,24 +1257,17 @@ int read_frame_internal(FormatContext *s, Packet *pkt)
if (cur_pkt.pts != -1 &&
cur_pkt.dts != -1 &&
cur_pkt.pts < cur_pkt.dts) {
LOGW("Invalid timestamps stream=%d, pts=%lld, dts=%lld, size=%d",
cur_pkt.stream_index, cur_pkt.pts, cur_pkt.dts, cur_pkt.size);
LOGW("Invalid timestamps stream=%d, pts=%lld, dts=%lld, size=%d", cur_pkt.stream_index, cur_pkt.pts, cur_pkt.dts, cur_pkt.size);
}
#ifdef XDEBUG
LOGD("read_packet stream=%d, pts=%lld, dts=%lld, size=%d, duration=%d",
cur_pkt.stream_index,
cur_pkt.pts,
cur_pkt.dts,
cur_pkt.size,
cur_pkt.duration);
LOGD("read_packet stream=%d, pts=%lld, dts=%lld, size=%d, duration=%d", cur_pkt.stream_index, cur_pkt.pts, cur_pkt.dts, cur_pkt.size, cur_pkt.duration);
#endif

if (st->need_parsing) {
if (!st->parser) {
st->parser = parser_init(st->codec->codec_id);
if (!st->parser) {
LOGE("Parser not found for codec(codec_id:%d)",
st->codec->codec_id);
LOGE("Parser not found for codec(codec_id:%d)", st->codec->codec_id);
return -1;
}
}
Expand All @@ -1303,10 +1288,7 @@ int read_frame_internal(FormatContext *s, Packet *pkt)
ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt);

#ifdef XDEBUG
LOGD("read_frame_internal stream=%d, pts=%lld, dts=%lld, "
"size=%d, duration=%d",
pkt->stream_index, pkt->pts, pkt->dts,
pkt->size, pkt->duration);
LOGD("read_frame_internal stream=%d, pts=%lld, dts=%lld, size=%d, duration=%d", pkt->stream_index, pkt->pts, pkt->dts, pkt->size, pkt->duration);
#endif
return ret;
}
Expand All @@ -1322,8 +1304,7 @@ int format_find_stream_info(FormatContext *ic)
Packet *pkt, pkt1;

#ifdef XDEBUG
LOGD("Before format_find_stream_info() pos: %lld",
old_offset);
LOGD("Before format_find_stream_info() pos: %lld", old_offset);
#endif

for (i = 0; i < ic->nb_streams; ++i) {
Expand All @@ -1337,8 +1318,7 @@ int format_find_stream_info(FormatContext *ic)
if (!st->parser) {
st->parser = parser_init(st->codec->codec_id);
if (!st->parser && st->need_parsing) {
LOGE("Parser not found for codec(codec_id:%d)",
st->codec->codec_id);
LOGE("Parser not found for codec(codec_id:%d)", st->codec->codec_id);
}
}

Expand Down Expand Up @@ -1380,8 +1360,7 @@ int format_find_stream_info(FormatContext *ic)
}

if (read_size >= probesize) {
LOGW("Probe buffer size limit of %lld bytes reached",
probesize);
LOGW("Probe buffer size limit of %lld bytes reached", probesize);
break;
}

Expand Down Expand Up @@ -1434,8 +1413,7 @@ int process_input(FormatContext *ic, int stream_index)
return -1;

#ifdef XDEBUG
LOGI("demuxer -> stream: %d pkt_pts:%lld, pkt_dts:%lld size:%d duration:%d pos:%lld",
pkt.stream_index, pkt.pts, pkt.dts, pkt.size, pkt.duration, pkt.pos);
LOGI("demuxer -> stream: %d pkt_pts:%lld, pkt_dts:%lld size:%d duration:%d pos:%lld", pkt.stream_index, pkt.pts, pkt.dts, pkt.size, pkt.duration, pkt.pos);
#endif

if (pkt.dts != -1)
Expand All @@ -1444,8 +1422,7 @@ int process_input(FormatContext *ic, int stream_index)
pkt.pts += av_rescale_q(ic->ts_offset, AV_TIME_BASE_Q, st->time_base);

#ifdef XDEBUG
LOGI("demuxer+ffmpeg -> stream: %d pkt_pts:%lld, pkt_dts:%lld size:%d duration:%d pos:%lld",
pkt.stream_index, pkt.pts, pkt.dts, pkt.size, pkt.duration, pkt.pos);
LOGI("demuxer+ffmpeg -> stream: %d pkt_pts:%lld, pkt_dts:%lld size:%d duration:%d pos:%lld", pkt.stream_index, pkt.pts, pkt.dts, pkt.size, pkt.duration, pkt.pos);
#endif

do_streamcopy(ic, &pkt);
Expand Down Expand Up @@ -1482,8 +1459,7 @@ void write_frame(FormatContext *ic, Packet *pkt)
}

#ifdef XDEBUG
LOGI("muxer <- stream: %d pkt_pts:%lld pkt_dts:%lld size:%d duration:%d pos:%lld",
pkt->stream_index, pkt->pts, pkt->dts, pkt->size, pkt->duration, pkt->pos);
LOGI("muxer <- stream: %d pkt_pts:%lld pkt_dts:%lld size:%d duration:%d pos:%lld", pkt->stream_index, pkt->pts, pkt->dts, pkt->size, pkt->duration, pkt->pos);
#endif

ret = interleaved_write_frame(ic, pkt);
Expand All @@ -1500,8 +1476,7 @@ int interleaved_write_frame(FormatContext *ic, Packet *pkt)

if (pkt->stream_index < 0 ||
pkt->stream_index >= (int) ic->nb_streams) {
LOGE("Invalid packet stream index: %d",
pkt->stream_index);
LOGE("Invalid packet stream index: %d", pkt->stream_index);
return -1;
}

Expand All @@ -1525,8 +1500,7 @@ int interleaved_write_frame(FormatContext *ic, Packet *pkt)
}

#ifdef XDEBUG
LOGI("opkt.stream_index=%d, opkt.pts=%lld",
opkt.stream_index, opkt.pts);
LOGI("opkt.stream_index=%d, opkt.pts=%lld", opkt.stream_index, opkt.pts);
#endif
if (ic->cb) {
MediaType mt = ic->streams[opkt.stream_index]->codec->codec_type;
Expand Down Expand Up @@ -1599,9 +1573,7 @@ int interleave_packet_per_dts(FormatContext *s, Packet *out,
}

if (delta_dts > s->max_interleave_delta) {
LOGE("Delay between the first packet and last packet in the "
"muxing queue is %lld > %lld: forcing output",
delta_dts, s->max_interleave_delta);
LOGE("Delay between the first packet and last packet in the muxing queue is %lld > %lld: forcing output", delta_dts, s->max_interleave_delta);
flush = 1;
}
}
Expand Down Expand Up @@ -1640,8 +1612,7 @@ int write_trailer(FormatContext *s)
break;

#ifdef XDEBUG
LOGI("opkt.stream_index=%d, opkt.pts=%lld",
opkt.stream_index, opkt.pts);
LOGI("opkt.stream_index=%d, opkt.pts=%lld", opkt.stream_index, opkt.pts);
#endif

if (s->cb) {
Expand Down
Loading

0 comments on commit fc257ac

Please sign in to comment.