Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/azatoth/minidlna.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Fürstenberg <carl@excito.com>2011-07-21 17:53:34 +0400
committerCarl Fürstenberg <carl@excito.com>2011-07-21 17:53:34 +0400
commit1c2eb919ab9b30a99ec25759eeeae49f682ef0b1 (patch)
tree137c6190f2c5921f20f120c9b88a408e4a0ee426
parent39a60e8111d4163de28b3e3c9dda621485975bc5 (diff)
parentec7b4b3fb9c786a8b733eea0dacbe239bd697d7d (diff)
Merge branch 'cvs'
-rw-r--r--NEWS3
-rw-r--r--src/metadata.c65
-rw-r--r--src/metadata.h5
-rw-r--r--src/tagutils/tagutils-wav.c4
-rw-r--r--src/upnpglobalvars.h2
-rw-r--r--src/utils.c15
6 files changed, 50 insertions, 44 deletions
diff --git a/NEWS b/NEWS
index 1911719..089411e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
-1.0.21 - Released 00-MONTH-2011
+1.0.21 - Released 18-July-2011
--------------------------------
+- Fix a few issues with new libav/ffmpeg versions.
- Fix FF/REW of AVI files on Samsung Series B TV's.
- Fix a crash bug when playing music on TiVo.
- Add the ability to change the root media container.
diff --git a/src/metadata.c b/src/metadata.c
index 6ea764d..9ecd44d 100644
--- a/src/metadata.c
+++ b/src/metadata.c
@@ -53,11 +53,10 @@
#define FF_PROFILE_H264_HIGH 100
#endif
#define FF_PROFILE_SKIP -100
-#ifndef CODEC_TYPE_AUDIO
-#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
-#endif
-#ifndef CODEC_TYPE_VIDEO
-#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
+
+#if LIBAVCODEC_VERSION_MAJOR < 53
+#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
+#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
#endif
#define FLAG_TITLE 0x00000001
@@ -93,34 +92,41 @@ enum audio_profiles {
/* This function shamelessly copied from libdlna */
#define MPEG_TS_SYNC_CODE 0x47
-#define MPEG_TS_PACKET_LENGTH 188 /* prepends 4 bytes to TS packet */
+#define MPEG_TS_PACKET_LENGTH 188
#define MPEG_TS_PACKET_LENGTH_DLNA 192 /* prepends 4 bytes to TS packet */
int
-dlna_timestamp_is_present(const char * filename)
+dlna_timestamp_is_present(const char * filename, int * raw_packet_size)
{
- unsigned char buffer[2*MPEG_TS_PACKET_LENGTH_DLNA+1];
+ unsigned char buffer[3*MPEG_TS_PACKET_LENGTH_DLNA];
int fd, i;
/* read file header */
fd = open(filename, O_RDONLY);
- read(fd, buffer, MPEG_TS_PACKET_LENGTH_DLNA*2);
+ read(fd, buffer, MPEG_TS_PACKET_LENGTH_DLNA*3);
close(fd);
for( i=0; i < MPEG_TS_PACKET_LENGTH_DLNA; i++ )
{
if( buffer[i] == MPEG_TS_SYNC_CODE )
{
- if (buffer[i + MPEG_TS_PACKET_LENGTH_DLNA] == MPEG_TS_SYNC_CODE)
+ if (buffer[i + MPEG_TS_PACKET_LENGTH_DLNA] == MPEG_TS_SYNC_CODE &&
+ buffer[i + MPEG_TS_PACKET_LENGTH_DLNA*2] == MPEG_TS_SYNC_CODE)
{
+ *raw_packet_size = MPEG_TS_PACKET_LENGTH_DLNA;
if (buffer[i+MPEG_TS_PACKET_LENGTH] == 0x00 &&
buffer[i+MPEG_TS_PACKET_LENGTH+1] == 0x00 &&
buffer[i+MPEG_TS_PACKET_LENGTH+2] == 0x00 &&
buffer[i+MPEG_TS_PACKET_LENGTH+3] == 0x00)
- break;
+ return 0;
else
return 1;
+ } else if (buffer[i + MPEG_TS_PACKET_LENGTH] == MPEG_TS_SYNC_CODE &&
+ buffer[i + MPEG_TS_PACKET_LENGTH*2] == MPEG_TS_SYNC_CODE) {
+ *raw_packet_size = MPEG_TS_PACKET_LENGTH;
+ return 0;
}
}
}
+ *raw_packet_size = 0;
return 0;
}
@@ -641,11 +647,10 @@ GetVideoMetadata(const char * path, char * name)
struct stat file;
int ret, i;
struct tm *modtime;
- AVFormatContext *ctx;
+ AVFormatContext *ctx = NULL;
AVCodecContext *ac = NULL, *vc = NULL;
int audio_stream = -1, video_stream = -1;
enum audio_profiles audio_profile = PROFILE_AUDIO_UNKNOWN;
- tsinfo_t *ts;
char fourcc[4];
sqlite_int64 album_art = 0;
char nfo[PATH_MAX], *ext;
@@ -663,7 +668,11 @@ GetVideoMetadata(const char * path, char * name)
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size);
av_register_all();
+ #if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(2<<8)+0)
+ if( avformat_open_input(&ctx, path, NULL, NULL) != 0 )
+ #else
if( av_open_input_file(&ctx, path, NULL, 0, NULL) != 0 )
+ #endif
{
DPRINTF(E_WARN, L_METADATA, "Opening %s failed!\n", path);
return 0;
@@ -673,14 +682,14 @@ GetVideoMetadata(const char * path, char * name)
for( i=0; i<ctx->nb_streams; i++)
{
if( audio_stream == -1 &&
- ctx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO )
+ ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
{
audio_stream = i;
ac = ctx->streams[audio_stream]->codec;
continue;
}
else if( video_stream == -1 &&
- ctx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO )
+ ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
{
video_stream = i;
vc = ctx->streams[video_stream]->codec;
@@ -866,8 +875,10 @@ GetVideoMetadata(const char * path, char * name)
off = sprintf(m.dlna_pn, "MPEG_");
if( strcmp(ctx->iformat->name, "mpegts") == 0 )
{
- DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s MPEG2 TS\n",
- video_stream, basename(path), m.resolution);
+ int raw_packet_size;
+ int dlna_ts_present = dlna_timestamp_is_present(path, &raw_packet_size);
+ DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s MPEG2 TS packet size %d\n",
+ video_stream, basename(path), m.resolution, raw_packet_size);
off += sprintf(m.dlna_pn+off, "TS_");
if( (vc->width >= 1280) &&
(vc->height >= 720) )
@@ -883,18 +894,17 @@ GetVideoMetadata(const char * path, char * name)
else
off += sprintf(m.dlna_pn+off, "NA");
}
- ts = ctx->priv_data;
- if( ts->packet_size == MPEG_TS_PACKET_LENGTH_DLNA )
+ if( raw_packet_size == MPEG_TS_PACKET_LENGTH_DLNA )
{
- if( dlna_timestamp_is_present(path) )
+ if (dlna_ts_present)
ts_timestamp = VALID;
else
ts_timestamp = EMPTY;
}
- else if( ts->packet_size != MPEG_TS_PACKET_LENGTH )
+ else if( raw_packet_size != MPEG_TS_PACKET_LENGTH )
{
DPRINTF(E_DEBUG, L_METADATA, "Unsupported DLNA TS packet size [%d] (%s)\n",
- ts->packet_size, basename(path));
+ raw_packet_size, basename(path));
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -943,6 +953,8 @@ GetVideoMetadata(const char * path, char * name)
{
AVRational display_aspect_ratio;
int fps, interlaced;
+ int raw_packet_size;
+ int dlna_ts_present = dlna_timestamp_is_present(path, &raw_packet_size);
off += sprintf(m.dlna_pn+off, "TS_");
if (vc->sample_aspect_ratio.num) {
@@ -1070,19 +1082,18 @@ GetVideoMetadata(const char * path, char * name)
}
if( !m.dlna_pn )
break;
- ts = ctx->priv_data;
- if( ts->packet_size == MPEG_TS_PACKET_LENGTH_DLNA )
+ if( raw_packet_size == MPEG_TS_PACKET_LENGTH_DLNA )
{
if( vc->profile == FF_PROFILE_H264_HIGH ||
- dlna_timestamp_is_present(path) )
+ dlna_ts_present )
ts_timestamp = VALID;
else
ts_timestamp = EMPTY;
}
- else if( ts->packet_size != MPEG_TS_PACKET_LENGTH )
+ else if( raw_packet_size != MPEG_TS_PACKET_LENGTH )
{
DPRINTF(E_DEBUG, L_METADATA, "Unsupported DLNA TS packet size [%d] (%s)\n",
- ts->packet_size, basename(path));
+ raw_packet_size, basename(path));
free(m.dlna_pn);
m.dlna_pn = NULL;
}
diff --git a/src/metadata.h b/src/metadata.h
index 5e9344d..7a01105 100644
--- a/src/metadata.h
+++ b/src/metadata.h
@@ -42,11 +42,6 @@ typedef struct metadata_s {
char *dlna_pn;
} metadata_t;
-typedef struct tsinfo_s {
- int x;
- int packet_size;
-} tsinfo_t;
-
typedef enum {
AAC_INVALID = 0,
AAC_MAIN = 1, /* AAC Main */
diff --git a/src/tagutils/tagutils-wav.c b/src/tagutils/tagutils-wav.c
index f85d6c3..61a1f6c 100644
--- a/src/tagutils/tagutils-wav.c
+++ b/src/tagutils/tagutils-wav.c
@@ -36,7 +36,7 @@ _get_wavtags(char *filename, struct song_metadata *psong)
uint32_t len;
unsigned char hdr[12];
unsigned char fmt[16];
- uint32_t chunk_data_length;
+ //uint32_t chunk_data_length;
uint32_t format_data_length = 0;
uint32_t compression_code = 0;
uint32_t channel_count = 0;
@@ -75,7 +75,7 @@ _get_wavtags(char *filename, struct song_metadata *psong)
return -1;
}
- chunk_data_length = GET_WAV_INT32(hdr + 4);
+ //chunk_data_length = GET_WAV_INT32(hdr + 4);
/* now, walk through the chunks */
current_offset = 12;
diff --git a/src/upnpglobalvars.h b/src/upnpglobalvars.h
index 3e871d8..893b23c 100644
--- a/src/upnpglobalvars.h
+++ b/src/upnpglobalvars.h
@@ -58,7 +58,7 @@
#include <sqlite3.h>
-#define MINIDLNA_VERSION "1.0.20.3"
+#define MINIDLNA_VERSION "1.0.21"
#ifdef NETGEAR
# define SERVER_NAME "ReadyDLNA"
diff --git a/src/utils.c b/src/utils.c
index 136fbda..22fe37a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -191,7 +191,7 @@ make_dir(char * path, mode_t mode)
struct stat st;
do {
- c = 0;
+ c = '\0';
/* Bypass leading non-'/'s and then subsequent '/'s. */
while (*s) {
@@ -200,7 +200,7 @@ make_dir(char * path, mode_t mode)
++s;
} while (*s == '/');
c = *s; /* Save the current char */
- *s = 0; /* and replace it with nul. */
+ *s = '\0'; /* and replace it with nul. */
break;
}
++s;
@@ -209,9 +209,11 @@ make_dir(char * path, mode_t mode)
if (mkdir(path, mode) < 0) {
/* If we failed for any other reason than the directory
* already exists, output a diagnostic and return -1.*/
- if (errno != EEXIST
- || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
- break;
+ if (errno != EEXIST || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
+ DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
+ if (c)
+ *s = c;
+ return -1;
}
}
if (!c)
@@ -221,9 +223,6 @@ make_dir(char * path, mode_t mode)
*s = c;
} while (1);
-
- DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
- return -1;
}
int