* Don't depend on libavutil carrying the ff_get_fourcc() function.

* Try determining our IP address with hostname lookup before trying eth0 and eth1.
This commit is contained in:
Justin Maggard 2009-02-02 22:10:39 +00:00
parent 7e30949498
commit 3f454a5762
4 changed files with 33 additions and 4 deletions

View File

@ -16,6 +16,7 @@
#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#if defined(sun)
#include <sys/sockio.h>
#endif
@ -55,6 +56,23 @@ getifaddr(const char * ifname, char * buf, int len)
return 0;
}
int
getsysaddr(char * buf, int len)
{
char hn[256];
struct in_addr *addr;
struct hostent *host;
memset(buf, '\0', len);
gethostname(hn, sizeof(hn));
host = gethostbyname(hn);
if( !host )
return -1;
addr = (struct in_addr*)host->h_addr;
strncpy(buf, inet_ntoa(*addr), len);
return 0;
}
int
getifhwaddr(const char * ifname, char * buf, int len)

View File

@ -14,6 +14,9 @@
int
getifaddr(const char * ifname, char * buf, int len);
int
getsysaddr(char * buf, int len);
int
getifhwaddr(const char * ifname, char * buf, int len);

View File

@ -92,6 +92,13 @@ dlna_timestamp_is_present(const char * filename)
return 0;
}
/* This function taken from libavutil (ffmpeg), because it's not included with all versions of libavutil. */
int
get_fourcc(const char *s)
{
return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
}
sqlite_int64
GetFolderMetadata(const char * name, const char * artist, const char * genre, const char * album_art)
{
@ -753,17 +760,17 @@ GetVideoMetadata(const char * path, char * name)
printf("Stream %d of %s is h.264\n", video_stream, path);
break;
case CODEC_ID_MPEG4:
if( ctx->streams[video_stream]->codec->codec_tag == ff_get_fourcc("XVID") )
if( ctx->streams[video_stream]->codec->codec_tag == get_fourcc("XVID") )
{
printf("Stream %d of %s is %s XViD\n", video_stream, path, m.resolution);
asprintf(&m.mime, "video/divx");
}
else if( ctx->streams[video_stream]->codec->codec_tag == ff_get_fourcc("DX50") )
else if( ctx->streams[video_stream]->codec->codec_tag == get_fourcc("DX50") )
{
printf("Stream %d of %s is %s DiVX5\n", video_stream, path, m.resolution);
asprintf(&m.mime, "video/divx");
}
else if( ctx->streams[video_stream]->codec->codec_tag == ff_get_fourcc("DIVX") )
else if( ctx->streams[video_stream]->codec->codec_tag == get_fourcc("DIVX") )
{
printf("Stream %d of %s is DiVX\n", video_stream, path);
asprintf(&m.mime, "video/divx");

View File

@ -263,7 +263,8 @@ init(int argc, char * * argv, struct runtime_vars * v)
/*v->n_lan_addr = 0;*/
char ext_ip_addr[INET_ADDRSTRLEN];
if( (getifaddr("eth0", ext_ip_addr, INET_ADDRSTRLEN) < 0) &&
if( (getsysaddr(ext_ip_addr, INET_ADDRSTRLEN) < 0) &&
(getifaddr("eth0", ext_ip_addr, INET_ADDRSTRLEN) < 0) &&
(getifaddr("eth1", ext_ip_addr, INET_ADDRSTRLEN) < 0) )
{
printf("No IP!\n");