Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libav #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright (c) [2015] Qualcomm Technologies International, Ltd.
All Rights Reserved.
Qualcomm Technologies Inc. Confidential and Proprietary.
Not a Contribution. Notifications and licenses are retained for attribution
purposes only . Your use of this code is governed by the terms of your license
agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
Except as may be granted by separate express written agreement, this file
provides no rights under or license to any QTIL or its affiliates patents,
trademarks, copyrights,or other intellectual property.
31 changes: 16 additions & 15 deletions lib/mediainfo.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/****************************************************************************
**
** Copyright (c) [2015] Qualcomm Technologies International, Ltd.
** All Rights Reserved.
** Qualcomm Technologies Inc. Confidential and Proprietary.
** Not a Contribution. Notifications and licenses are retained for attribution
** purposes only . Your use of this code is governed by the terms of your
** license agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
** Except as may be granted by separate express written agreement, this file
** provides no rights under or license to any QTIL or its affiliates patents,
** trademarks, copyrights,or other intellectual property.
**
****************************************************************************/

#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
Expand Down Expand Up @@ -78,7 +92,6 @@ static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
/* "user interface" functions */
static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
{
int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
AVStream *st = ic->streams[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);

Expand Down Expand Up @@ -217,8 +230,7 @@ void collect_codec_info (AVCodecContext *enc)
if (enc->sample_rate) {
snprintf (mMetadataValues[MetaNameMap[METADATA_KEY_AUDIO_SAMPLE_RATE].key], MAX_METADATA_STRING_LENGTH, "%d Hz", enc->sample_rate);
}
//av_strlcat(buf, ", ", buf_size);
//av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
av_get_channel_layout_string (mMetadataValues[MetaNameMap[METADATA_KEY_AUDIO_CHANNEL].key], MAX_METADATA_STRING_LENGTH, enc->channels, enc->channel_layout);
if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
snprintf (mMetadataValues[MetaNameMap[METADATA_KEY_AUDIO_SAMPLE_FORMAT].key], MAX_METADATA_STRING_LENGTH, "%s", av_get_sample_fmt_name(enc->sample_fmt));
}
Expand Down Expand Up @@ -246,7 +258,6 @@ void collect_codec_info (AVCodecContext *enc)
void dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
{
int i;
const char *mimefmt = "";
uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
if (ic->nb_streams && !printed)
return;
Expand Down Expand Up @@ -328,7 +339,6 @@ void dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
{
AVStream *st = ic->streams[i];
AVCodecContext *codec = st->codec;
AVCodec *decoder = avcodec_find_decoder (codec->codec_id);
int codec_type = codec->codec_type;

if (codec_type == AVMEDIA_TYPE_VIDEO) {
Expand All @@ -349,27 +359,18 @@ void dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
dump_stream_format(ic, i, index, is_output);
}

/**** Do not change below two blocks! ****/
if (cnt_a > 0)
{
snprintf (mMetadataValues[MetaNameMap[METADATA_KEY_HAS_AUDIO].key], MAX_METADATA_STRING_LENGTH, "True");
mimefmt = "audio/%s";
}

if (cnt_v > 0)
{
snprintf (mMetadataValues[MetaNameMap[METADATA_KEY_HAS_VIDEO].key], MAX_METADATA_STRING_LENGTH, "True");
mimefmt = "video/%s";
}
/**** ****/

if (ic->iformat) {
for (i = 0; i < (int) DIM (MimeMap); i++) {
if (strcmp (ic->iformat->name, MimeMap[i].ffname) == 0) {
snprintf (mMetadataValues[METADATA_KEY_MIMETYPE],
MAX_METADATA_STRING_LENGTH, mimefmt, MimeMap[i].mime);
}
}
snprintf (mMetadataValues[MetaNameMap[METADATA_KEY_FILE_FORMAT].key], MAX_METADATA_STRING_LENGTH, "%s", ic->iformat->name);
}

av_free(printed);
Expand Down
103 changes: 51 additions & 52 deletions lib/mediainfo.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/****************************************************************************
**
** Copyright (c) [2015] Qualcomm Technologies International, Ltd.
** All Rights Reserved.
** Qualcomm Technologies Inc. Confidential and Proprietary.
** Not a Contribution. Notifications and licenses are retained for attribution
** purposes only . Your use of this code is governed by the terms of your
** license agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
** Except as may be granted by separate express written agreement, this file
** provides no rights under or license to any QTIL or its affiliates patents,
** trademarks, copyrights,or other intellectual property.
**
****************************************************************************/

#ifndef __MEDIAINFO_H__
#define __MEDIAINFO_H__
#include <stdio.h>
Expand All @@ -14,106 +28,91 @@ enum {
METADATA_KEY_DURATION = 0,
METADATA_KEY_START_TIME ,
METADATA_KEY_BITRATE ,
METADATA_KEY_MIMETYPE ,
METADATA_KEY_FILE_FORMAT ,
METADATA_KEY_HAS_VIDEO ,
METADATA_KEY_HAS_AUDIO ,
METADATA_KEY_VIDEO_CODEC ,
METADATA_KEY_AUDIO_CODEC ,
METADATA_KEY_VIDEO_PROFILE ,
METADATA_KEY_AUDIO_PROFILE ,
METADATA_KEY_AUDIO_SAMPLE_RATE ,
METADATA_KEY_AUDIO_SAMPLE_FORMAT ,
METADATA_KEY_AUDIO_CHANNEL ,
METADATA_KEY_AUDIO_SAMPLE_RATE ,
METADATA_KEY_AUDIO_SAMPLE_FORMAT ,
METADATA_KEY_FRAME_RATE ,
METADATA_KEY_WIDTH ,
METADATA_KEY_HEIGHT ,
METADATA_KEY_TBN ,
METADATA_KEY_TBC ,
METADATA_KEY_PAR ,
METADATA_KEY_DAR ,
METADATA_KEY_TITLE ,
METADATA_KEY_ALBUM ,
METADATA_KEY_ARTIST ,
METADATA_KEY_GENRE ,
METADATA_KEY_WIDTH ,
METADATA_KEY_HEIGHT ,
METADATA_KEY_TBN ,
METADATA_KEY_TBC ,
METADATA_KEY_PAR ,
METADATA_KEY_DAR ,
METADATA_KEY_TITLE ,
METADATA_KEY_ALBUM ,
METADATA_KEY_ARTIST ,
METADATA_KEY_GENRE ,
METADATA_KEY_ALBUMARTIST ,
METADATA_KEY_LANGUAGE ,
METADATA_KEY_CD_TRACK_NUMBER ,
METADATA_KEY_DATE ,
METADATA_KEY_TYER ,
METADATA_KEY_CD_TRACK_NUMBER ,
METADATA_KEY_DATE ,
METADATA_KEY_TYER ,
METADATA_KEY_COMMENT ,
METADATA_KEY_TAGGING_TIME ,
METADATA_KEY_TOOL_NAME ,
METADATA_KEY_ENCODER ,
METADATA_KEY_YEAR ,
METADATA_KEY_YEAR ,
METADATA_KEY_COMPOSER ,
METADATA_KEY_ORGANIZATION ,
METADATA_KEY_AUTHOR ,
METADATA_KEY_COPYRIGHT = 36,
METADATA_KEY_AUTHOR ,
METADATA_KEY_COPYRIGHT = 37,

// Add more here...
};

MetaNameMapEntry MetaNameMap[] = {
{METADATA_KEY_DURATION, "Duration"},
{METADATA_KEY_START_TIME, "Start Sime"},
{METADATA_KEY_START_TIME, "Start Time"},
{METADATA_KEY_BITRATE, "Bitrate"},
{METADATA_KEY_MIMETYPE, "Mime"},
{METADATA_KEY_FILE_FORMAT, "Format"},
{METADATA_KEY_HAS_VIDEO, "Has Video"},
{METADATA_KEY_HAS_AUDIO, "Has Audio"},
{METADATA_KEY_VIDEO_CODEC, "Video"},
{METADATA_KEY_AUDIO_CODEC, "Audio"},
{METADATA_KEY_VIDEO_PROFILE, "Video Profile"},
{METADATA_KEY_AUDIO_PROFILE, "Audio Profile"},
{METADATA_KEY_AUDIO_SAMPLE_RATE, "Sample Rate"},
{METADATA_KEY_AUDIO_SAMPLE_FORMAT, "Sample Format"},
{METADATA_KEY_VIDEO_PROFILE, "Video Profile"},
{METADATA_KEY_AUDIO_PROFILE, "Audio Profile"},
{METADATA_KEY_AUDIO_CHANNEL, "Channel"},
{METADATA_KEY_AUDIO_SAMPLE_RATE, "Sample Rate"},
{METADATA_KEY_AUDIO_SAMPLE_FORMAT, "Sample Format"},
{METADATA_KEY_FRAME_RATE, "Framerate"},
{METADATA_KEY_WIDTH, "Width"},
{METADATA_KEY_HEIGHT, "Height"},
{METADATA_KEY_TBN, "TBN"},
{METADATA_KEY_TBC, "TBC"},
{METADATA_KEY_PAR, "PAR"},
{METADATA_KEY_DAR, "DAR"},
{METADATA_KEY_TBN, "TBN"},
{METADATA_KEY_TBC, "TBC"},
{METADATA_KEY_PAR, "PAR"},
{METADATA_KEY_DAR, "DAR"},
{METADATA_KEY_TITLE, "Title"},
{METADATA_KEY_ALBUM, "Album"},
{METADATA_KEY_ARTIST, "Artist"},
{METADATA_KEY_GENRE, "Genre"},
{METADATA_KEY_ALBUMARTIST, "Album_Artist"},
{METADATA_KEY_LANGUAGE, "Language"},
{METADATA_KEY_CD_TRACK_NUMBER, "Track"},
{METADATA_KEY_DATE, "Date"},
{METADATA_KEY_TYER, "Tyer"},
{METADATA_KEY_CD_TRACK_NUMBER, "Track"},
{METADATA_KEY_DATE, "Date"},
{METADATA_KEY_TYER, "Tyer"},
{METADATA_KEY_COMMENT, "Comment"},
{METADATA_KEY_TAGGING_TIME, "Tagging Time"},
{METADATA_KEY_TOOL_NAME, "Tool Name"},
{METADATA_KEY_ENCODER, "Encode"},
{METADATA_KEY_YEAR, "Year"},
{METADATA_KEY_YEAR, "Year"},
{METADATA_KEY_COMPOSER, "Composer"},
{METADATA_KEY_ORGANIZATION, "Organization"},
{METADATA_KEY_AUTHOR, "Author"},
{METADATA_KEY_COPYRIGHT, "Copyright"},
};

typedef struct MimeMapEntry
{
const char *ffname;
const char *mime;
} MimeMapEntry;

MimeMapEntry MimeMap[] = {
{"mp3", "mpeg"},
{"matroska", "x-matroska"},
{"mov,mp4,m4a,3gp,3g2,mj2", "mp4"},
{"mpeg", "mpeg"},
{"avi", "avi"},
{"ogg", "ogg"},
{"rm", "rm"},
{"ape", "ape"}
};

const int MAX_METADATA_STRING_LENGTH = 128;
const int NUM_METADATA_KEYS = 37;
const int NUM_METADATA_KEYS = 38;

#define DIM(a) (sizeof(a)/ sizeof(a[0]))
char mMetadataValues[37][128];
char mMetadataValues[38][128];
#endif

void media_info (const char *filename, char msg[]);
Expand Down
14 changes: 14 additions & 0 deletions test/testmediainfo.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/****************************************************************************
**
** Copyright (c) [2015] Qualcomm Technologies International, Ltd.
** All Rights Reserved.
** Qualcomm Technologies Inc. Confidential and Proprietary.
** Not a Contribution. Notifications and licenses are retained for attribution
** purposes only . Your use of this code is governed by the terms of your
** license agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
** Except as may be granted by separate express written agreement, this file
** provides no rights under or license to any QTIL or its affiliates patents,
** trademarks, copyrights,or other intellectual property.
**
****************************************************************************/

#include <stdlib.h>
#include "mediainfo.h"

Expand Down