* Streamline some TiVo ifdefs.
This commit is contained in:
parent
61fbce18ba
commit
5f14c68597
20
metadata.c
20
metadata.c
@ -210,26 +210,6 @@ dlna_timestamp_is_present(const char *filename, int *raw_packet_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef TIVO_SUPPORT
|
||||
int
|
||||
is_tivo_file(const char *path)
|
||||
{
|
||||
unsigned char buf[5];
|
||||
unsigned char hdr[5] = { 'T','i','V','o','\0' };
|
||||
int fd;
|
||||
|
||||
/* read file header */
|
||||
fd = open(path, O_RDONLY);
|
||||
if( !fd )
|
||||
return 0;
|
||||
if( read(fd, buf, 5) < 0 )
|
||||
buf[0] = 'X';
|
||||
close(fd);
|
||||
|
||||
return !memcmp(buf, hdr, 5);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
check_for_captions(const char *path, int64_t detailID)
|
||||
{
|
||||
|
@ -90,10 +90,8 @@
|
||||
#include "scanner.h"
|
||||
#include "inotify.h"
|
||||
#include "log.h"
|
||||
#ifdef TIVO_SUPPORT
|
||||
#include "tivo_beacon.h"
|
||||
#include "tivo_utils.h"
|
||||
#endif
|
||||
|
||||
#if SQLITE_VERSION_NUMBER < 3005001
|
||||
# warning "Your SQLite3 library appears to be too old! Please use 3.5.1 or newer."
|
||||
|
19
tivo_utils.c
19
tivo_utils.c
@ -140,4 +140,23 @@ TiVoRandomSeedFunc(sqlite3_context *context, int argc, sqlite3_value **argv)
|
||||
seedRandomness(sizeof(r), &r, seed);
|
||||
sqlite3_result_int64(context, r);
|
||||
}
|
||||
|
||||
int
|
||||
is_tivo_file(const char *path)
|
||||
{
|
||||
unsigned char buf[5];
|
||||
unsigned char hdr[5] = { 'T','i','V','o','\0' };
|
||||
int fd;
|
||||
|
||||
/* read file header */
|
||||
fd = open(path, O_RDONLY);
|
||||
if( !fd )
|
||||
return 0;
|
||||
if( read(fd, buf, 5) < 0 )
|
||||
buf[0] = 'X';
|
||||
close(fd);
|
||||
|
||||
return !memcmp(buf, hdr, 5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,7 @@
|
||||
* along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#ifdef TIVO_SUPPORT
|
||||
#include <sqlite3.h>
|
||||
|
||||
@ -37,4 +38,9 @@ decodeString(char *string, int inplace);
|
||||
void
|
||||
TiVoRandomSeedFunc(sqlite3_context *context, int argc, sqlite3_value **argv);
|
||||
|
||||
int
|
||||
is_tivo_file(const char *path);
|
||||
|
||||
#else
|
||||
#define decodeString(X, Y) ({})
|
||||
#endif
|
||||
|
20
upnphttp.c
20
upnphttp.c
@ -75,10 +75,8 @@
|
||||
#include "log.h"
|
||||
#include "sql.h"
|
||||
#include <libexif/exif-loader.h>
|
||||
#ifdef TIVO_SUPPORT
|
||||
#include "tivo_utils.h"
|
||||
#include "tivo_commands.h"
|
||||
#endif
|
||||
|
||||
#include "sendfile.h"
|
||||
|
||||
@ -1624,14 +1622,14 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
||||
int width=640, height=480, dstw, dsth, size;
|
||||
int srcw, srch;
|
||||
unsigned char * data = NULL;
|
||||
char *path, *file_path;
|
||||
char *resolution;
|
||||
char *path, *file_path = NULL;
|
||||
char *resolution = NULL;
|
||||
char *key, *val;
|
||||
char *saveptr, *item=NULL;
|
||||
char *saveptr, *item = NULL;
|
||||
int rotate;
|
||||
/* Not implemented yet *
|
||||
char *pixelshape=NULL; */
|
||||
int64_t id;
|
||||
long long id;
|
||||
int rows=0, chunked, ret;
|
||||
image_s *imsrc = NULL, *imdst = NULL;
|
||||
int scale = 1;
|
||||
@ -1639,16 +1637,18 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
||||
id = strtoll(object, &saveptr, 10);
|
||||
snprintf(buf, sizeof(buf), "SELECT PATH, RESOLUTION, ROTATION from DETAILS where ID = '%lld'", (long long)id);
|
||||
ret = sql_get_table(db, buf, &result, &rows, NULL);
|
||||
if( (ret != SQLITE_OK) )
|
||||
if( ret != SQLITE_OK )
|
||||
{
|
||||
DPRINTF(E_ERROR, L_HTTP, "Didn't find valid file for %lld!\n", id);
|
||||
Send500(h);
|
||||
return;
|
||||
}
|
||||
if( rows )
|
||||
{
|
||||
file_path = result[3];
|
||||
resolution = result[4];
|
||||
rotate = result[5] ? atoi(result[5]) : 0;
|
||||
if( !rows || !file_path || !resolution || (access(file_path, F_OK) != 0) )
|
||||
}
|
||||
if( !file_path || !resolution || (access(file_path, F_OK) != 0) )
|
||||
{
|
||||
DPRINTF(E_WARN, L_HTTP, "%s not found, responding ERROR 404\n", object);
|
||||
sqlite3_free_table(result);
|
||||
@ -1661,9 +1661,7 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
||||
path = saveptr ? saveptr + 1 : object;
|
||||
for( item = strtok_r(path, "&,", &saveptr); item != NULL; item = strtok_r(NULL, "&,", &saveptr) )
|
||||
{
|
||||
#ifdef TIVO_SUPPORT
|
||||
decodeString(item, 1);
|
||||
#endif
|
||||
val = item;
|
||||
key = strsep(&val, "=");
|
||||
if( !val )
|
||||
|
Loading…
x
Reference in New Issue
Block a user