static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt) { char val_str[128]; AVStream *st = fmt_ctx->streams[pkt->stream_index]; probe_object_header("packet"); probe_str("codec_type", media_type_string(st->codec->codec_type)); probe_int("stream_index", pkt->stream_index); probe_str("pts", ts_value_string(val_str, sizeof(val_str), pkt->pts)); probe_str("pts_time", time_value_string(val_str, sizeof(val_str), pkt->pts, &st->time_base)); probe_str("dts", ts_value_string(val_str, sizeof(val_str), pkt->dts)); probe_str("dts_time", time_value_string(val_str, sizeof(val_str), pkt->dts, &st->time_base)); probe_str("duration", ts_value_string(val_str, sizeof(val_str), pkt->duration)); probe_str("duration_time", time_value_string(val_str, sizeof(val_str), pkt->duration, &st->time_base)); probe_str("size", value_string(val_str, sizeof(val_str), pkt->size, unit_byte_str)); probe_int("pos", pkt->pos); probe_str("flags", pkt->flags & AV_PKT_FLAG_KEY ? "K" : "_"); probe_object_footer("packet"); }
static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt) { char val_str[128]; AVStream *st = fmt_ctx->streams[pkt->stream_index]; printf("[PACKET]\n"); printf("codec_type=%s\n", media_type_string(st->codec->codec_type)); printf("stream_index=%d\n", pkt->stream_index); printf("pts=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->pts)); printf("pts_time=%s\n", time_value_string(val_str, sizeof(val_str), pkt->pts, &st->time_base)); printf("dts=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->dts)); printf("dts_time=%s\n", time_value_string(val_str, sizeof(val_str), pkt->dts, &st->time_base)); printf("duration=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->duration)); printf("duration_time=%s\n", time_value_string(val_str, sizeof(val_str), pkt->duration, &st->time_base)); printf("size=%s\n", value_string(val_str, sizeof(val_str), pkt->size, unit_byte_str)); printf("pos=%"PRId64"\n", pkt->pos); printf("flags=%c\n", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_'); printf("[/PACKET]\n"); }
static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) { AVStream *stream = fmt_ctx->streams[stream_idx]; AVCodecContext *dec_ctx; AVCodec *dec; char val_str[128]; AVDictionaryEntry *tag = NULL; AVRational display_aspect_ratio; printf("[STREAM]\n"); printf("index=%d\n", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { printf("codec_name=%s\n", dec->name); printf("codec_long_name=%s\n", dec->long_name); } else { printf("codec_name=unknown\n"); } printf("codec_type=%s\n", media_type_string(dec_ctx->codec_type)); printf("codec_time_base=%d/%d\n", dec_ctx->time_base.num, dec_ctx->time_base.den); /* print AVI/FourCC tag */ av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag); printf("codec_tag_string=%s\n", val_str); printf("codec_tag=0x%04x\n", dec_ctx->codec_tag); switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: printf("width=%d\n", dec_ctx->width); printf("height=%d\n", dec_ctx->height); printf("has_b_frames=%d\n", dec_ctx->has_b_frames); if (dec_ctx->sample_aspect_ratio.num) { printf("sample_aspect_ratio=%d:%d\n", dec_ctx->sample_aspect_ratio.num, dec_ctx->sample_aspect_ratio.den); av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, dec_ctx->width * dec_ctx->sample_aspect_ratio.num, dec_ctx->height * dec_ctx->sample_aspect_ratio.den, 1024*1024); printf("display_aspect_ratio=%d:%d\n", display_aspect_ratio.num, display_aspect_ratio.den); } printf("pix_fmt=%s\n", dec_ctx->pix_fmt != PIX_FMT_NONE ? av_pix_fmt_descriptors[dec_ctx->pix_fmt].name : "unknown"); break; case AVMEDIA_TYPE_AUDIO: printf("sample_rate=%s\n", value_string(val_str, sizeof(val_str), dec_ctx->sample_rate, unit_hertz_str)); printf("channels=%d\n", dec_ctx->channels); printf("bits_per_sample=%d\n", av_get_bits_per_sample(dec_ctx->codec_id)); break; } } else { printf("codec_type=unknown\n"); } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) printf("id=0x%x\n", stream->id); printf("r_frame_rate=%d/%d\n", stream->r_frame_rate.num, stream->r_frame_rate.den); printf("avg_frame_rate=%d/%d\n", stream->avg_frame_rate.num, stream->avg_frame_rate.den); printf("time_base=%d/%d\n", stream->time_base.num, stream->time_base.den); printf("start_time=%s\n", time_value_string(val_str, sizeof(val_str), stream->start_time, &stream->time_base)); printf("duration=%s\n", time_value_string(val_str, sizeof(val_str), stream->duration, &stream->time_base)); if (stream->nb_frames) printf("nb_frames=%"PRId64"\n", stream->nb_frames); while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) printf("TAG:%s=%s\n", tag->key, tag->value); printf("[/STREAM]\n"); }
static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) { AVStream *stream = fmt_ctx->streams[stream_idx]; AVCodecContext *dec_ctx; const AVCodec *dec; const char *profile; char val_str[128]; AVRational display_aspect_ratio, *sar = NULL; const AVPixFmtDescriptor *desc; probe_object_header("stream"); probe_int("index", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { probe_str("codec_name", dec->name); probe_str("codec_long_name", dec->long_name); } else { probe_str("codec_name", "unknown"); } probe_str("codec_type", media_type_string(dec_ctx->codec_type)); probe_str("codec_time_base", rational_string(val_str, sizeof(val_str), "/", &dec_ctx->time_base)); /* print AVI/FourCC tag */ av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag); probe_str("codec_tag_string", val_str); probe_str("codec_tag", tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag)); /* print profile, if there is one */ if (dec && (profile = av_get_profile_name(dec, dec_ctx->profile))) probe_str("profile", profile); switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: probe_int("width", dec_ctx->width); probe_int("height", dec_ctx->height); probe_int("coded_width", dec_ctx->coded_width); probe_int("coded_height", dec_ctx->coded_height); probe_int("has_b_frames", dec_ctx->has_b_frames); if (dec_ctx->sample_aspect_ratio.num) sar = &dec_ctx->sample_aspect_ratio; else if (stream->sample_aspect_ratio.num) sar = &stream->sample_aspect_ratio; if (sar) { probe_str("sample_aspect_ratio", rational_string(val_str, sizeof(val_str), ":", sar)); av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, dec_ctx->width * sar->num, dec_ctx->height * sar->den, 1024*1024); probe_str("display_aspect_ratio", rational_string(val_str, sizeof(val_str), ":", &display_aspect_ratio)); } desc = av_pix_fmt_desc_get(dec_ctx->pix_fmt); probe_str("pix_fmt", desc ? desc->name : "unknown"); probe_int("level", dec_ctx->level); probe_str("color_range", av_color_range_name(dec_ctx->color_range)); probe_str("color_space", av_color_space_name(dec_ctx->colorspace)); probe_str("color_trc", av_color_transfer_name(dec_ctx->color_trc)); probe_str("color_pri", av_color_primaries_name(dec_ctx->color_primaries)); probe_str("chroma_loc", av_chroma_location_name(dec_ctx->chroma_sample_location)); break; case AVMEDIA_TYPE_AUDIO: probe_str("sample_rate", value_string(val_str, sizeof(val_str), dec_ctx->sample_rate, unit_hertz_str)); probe_int("channels", dec_ctx->channels); probe_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); break; } } else { probe_str("codec_type", "unknown"); } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) probe_int("id", stream->id); probe_str("avg_frame_rate", rational_string(val_str, sizeof(val_str), "/", &stream->avg_frame_rate)); if (dec_ctx->bit_rate) probe_str("bit_rate", value_string(val_str, sizeof(val_str), dec_ctx->bit_rate, unit_bit_per_second_str)); probe_str("time_base", rational_string(val_str, sizeof(val_str), "/", &stream->time_base)); probe_str("start_time", time_value_string(val_str, sizeof(val_str), stream->start_time, &stream->time_base)); probe_str("duration", time_value_string(val_str, sizeof(val_str), stream->duration, &stream->time_base)); if (stream->nb_frames) probe_int("nb_frames", stream->nb_frames); probe_dict(stream->metadata, "tags"); if (stream->nb_side_data) { int i, j; probe_object_header("sidedata"); for (i = 0; i < stream->nb_side_data; i++) { const AVPacketSideData* sd = &stream->side_data[i]; switch (sd->type) { case AV_PKT_DATA_DISPLAYMATRIX: probe_object_header("displaymatrix"); probe_array_header("matrix", 1); for (j = 0; j < 9; j++) probe_int(NULL, ((int32_t *)sd->data)[j]); probe_array_footer("matrix", 1); probe_int("rotation", av_display_rotation_get((int32_t *)sd->data)); probe_object_footer("displaymatrix"); break; } } probe_object_footer("sidedata"); } probe_object_footer("stream"); }
BOOL print_ndas_unitdevice_info( const NDASCOMM_CONNECTION_INFO* pci) { BOOL success; int i; HNDAS hNdas = NULL; NDAS_UNITDEVICE_HARDWARE_INFO uinfo; NDASCOMM_IDE_REGISTER idereg; struct hd_driveid ideInfo; UINT64 sectors; TCHAR szBuffer[100]; const DWORD cchBuffer = sizeof(szBuffer) / sizeof(szBuffer[0]); /* NdasCommGetUnitDeviceStat requires NORMAL login type */ _ASSERTE(NDASCOMM_LOGIN_TYPE_NORMAL == pci->LoginType); API_CALL_JMP(fail, hNdas = NdasCommConnect(pci)); /* Unit Device Information */ ZeroMemory(&uinfo, sizeof(NDAS_UNITDEVICE_HARDWARE_INFO)); uinfo.Size = sizeof(NDAS_UNITDEVICE_HARDWARE_INFO); API_CALL_JMP(fail, NdasCommGetUnitDeviceHardwareInfo(hNdas, &uinfo)); sectors = _tprintf(_T(" Sector count : %I64d\n"), uinfo.SectorCount.QuadPart); _tprintf(_T(" Supports LBA : %s\n"), bool_string(uinfo.LBA)); _tprintf(_T(" Supports LBA48 : %s\n"), bool_string(uinfo.LBA48)); _tprintf(_T(" Supports PIO : %s\n"), bool_string(uinfo.PIO)); _tprintf(_T(" Supports DMA : %s\n"), bool_string(uinfo.DMA)); _tprintf(_T(" Supports UDMA : %s\n"), bool_string(uinfo.UDMA)); _tprintf(_T(" Model : %s\n"), uinfo.Model); _tprintf(_T(" Firmware Rev : %s\n"), uinfo.FirmwareRevision); _tprintf(_T(" Serial number : %s\n"), uinfo.SerialNumber); _tprintf(_T(" Media type : %s\n"), media_type_string(uinfo.MediaType)); _tprintf(_T("\n")); /* Additional IDE information using WIN_IDENTIFY command */ idereg.device.lba_head_nr = 0; idereg.device.dev = (0 == pci->UnitNo) ? 0 : 1; idereg.device.lba = 0; idereg.command.command = WIN_IDENTIFY; API_CALL_JMP(fail, NdasCommIdeCommand(hNdas, &idereg, NULL, 0, (PBYTE)&ideInfo, sizeof(ideInfo))); _tprintf(_T(" FLUSH CACHE : Supports - %s, Enabled - %s\n"), bool_string(ideInfo.command_set_2 & 0x1000), bool_string(ideInfo.cfs_enable_2 & 0x1000)); _tprintf(_T(" FLUSH CACHE EXT : Supports - %s, Enabled - %s\n"), bool_string(ideInfo.command_set_2 & 0x2000), bool_string(ideInfo.cfs_enable_2 & 0x2000)); /* Check Ultra DMA mode */ for (i = 7; i >= 0; i--) { if (ideInfo.dma_ultra & (0x01 << i)) { _tprintf(_T(" Ultra DMA mode: supports up to UDMA mode %d\n"), i); break; } } for (i = 7; i >= 0; i--) { if (ideInfo.dma_ultra & (0x01 << (i + 8))) { _tprintf(_T(" Current Ultra DMA mode: %d\n"), i); break; } } if (i < 0) { _tprintf(_T(" Ultra DMA mode is not selected\n")); } /* Check DMA mode */ for (i = 2; i >= 0; i--) { if (ideInfo.dma_mword & (0x01 << i)) { _tprintf(_T(" DMA mode: supports up to DMA mode %d\n"), i); break; } } for (i = 2; i >= 0; i--) { if (ideInfo.dma_mword & (0x01 << (i + 8))) { _tprintf(_T(" DMA mode %d selected\n"), i); break; } } if (i < 0) { _tprintf(_T(" DMA mode is not selected\n")); } _tprintf(_T("\n")); success = TRUE; fail: if (hNdas) { API_CALL(NdasCommDisconnect(hNdas)); } return success; }
static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) { AVStream *stream = fmt_ctx->streams[stream_idx]; AVCodecContext *dec_ctx; AVCodec *dec; const char *profile; char val_str[128]; AVRational display_aspect_ratio; probe_object_header("stream"); probe_int("index", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { probe_str("codec_name", dec->name); probe_str("codec_long_name", dec->long_name); } else { probe_str("codec_name", "unknown"); } probe_str("codec_type", media_type_string(dec_ctx->codec_type)); probe_str("codec_time_base", rational_string(val_str, sizeof(val_str), "/", &dec_ctx->time_base)); /* print AVI/FourCC tag */ av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag); probe_str("codec_tag_string", val_str); probe_str("codec_tag", tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag)); /* print profile, if there is one */ if (dec && (profile = av_get_profile_name(dec, dec_ctx->profile))) probe_str("profile", profile); switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: probe_int("width", dec_ctx->width); probe_int("height", dec_ctx->height); probe_int("has_b_frames", dec_ctx->has_b_frames); if (dec_ctx->sample_aspect_ratio.num) { probe_str("sample_aspect_ratio", rational_string(val_str, sizeof(val_str), ":", &dec_ctx->sample_aspect_ratio)); av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, dec_ctx->width * dec_ctx->sample_aspect_ratio.num, dec_ctx->height * dec_ctx->sample_aspect_ratio.den, 1024*1024); probe_str("display_aspect_ratio", rational_string(val_str, sizeof(val_str), ":", &display_aspect_ratio)); } probe_str("pix_fmt", dec_ctx->pix_fmt != PIX_FMT_NONE ? av_pix_fmt_descriptors[dec_ctx->pix_fmt].name : "unknown"); probe_int("level", dec_ctx->level); break; case AVMEDIA_TYPE_AUDIO: probe_str("sample_rate", value_string(val_str, sizeof(val_str), dec_ctx->sample_rate, unit_hertz_str)); probe_int("channels", dec_ctx->channels); probe_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); break; } } else { probe_str("codec_type", "unknown"); } if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) probe_int("id", stream->id); probe_str("avg_frame_rate", rational_string(val_str, sizeof(val_str), "/", &stream->avg_frame_rate)); probe_str("time_base", rational_string(val_str, sizeof(val_str), "/", &stream->time_base)); probe_str("start_time", time_value_string(val_str, sizeof(val_str), stream->start_time, &stream->time_base)); probe_str("duration", time_value_string(val_str, sizeof(val_str), stream->duration, &stream->time_base)); if (stream->nb_frames) probe_int("nb_frames", stream->nb_frames); probe_dict(stream->metadata, "tags"); probe_object_footer("stream"); }