mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-19 14:19:58 +01:00
add media tab, load files in veejay's working directory
git-svn-id: svn://code.dyne.org/veejay/trunk@1289 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
@@ -714,6 +714,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
int sig;
|
int sig;
|
||||||
|
|
||||||
|
|
||||||
while (veejay_get_state(info) != LAVPLAY_STATE_STOP)
|
while (veejay_get_state(info) != LAVPLAY_STATE_STOP)
|
||||||
{
|
{
|
||||||
usleep( 25000 );
|
usleep( 25000 );
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ enum {
|
|||||||
VIMS_TRACK_LIST = 5,
|
VIMS_TRACK_LIST = 5,
|
||||||
VIMS_SEQUENCE_LIST = 419,
|
VIMS_SEQUENCE_LIST = 419,
|
||||||
VIMS_KEYLIST = 420,
|
VIMS_KEYLIST = 420,
|
||||||
|
VIMS_WORKINGDIR = 421,
|
||||||
VIMS_SET_VOLUME = 300,
|
VIMS_SET_VOLUME = 300,
|
||||||
VIMS_FULLSCREEN = 301,
|
VIMS_FULLSCREEN = 301,
|
||||||
VIMS_SUSPEND = 254,
|
VIMS_SUSPEND = 254,
|
||||||
|
|||||||
@@ -8153,6 +8153,47 @@ void vj_event_toggle_bw( void *ptr, const char format[], va_list ap )
|
|||||||
use_bw_preview_ = 1;
|
use_bw_preview_ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vj_event_send_working_dir(void *ptr, const char format[], va_list ap)
|
||||||
|
{
|
||||||
|
veejay_t *v = (veejay_t*)ptr;
|
||||||
|
int args[2];
|
||||||
|
char str[2048];
|
||||||
|
P_A(args,str,format,ap);
|
||||||
|
|
||||||
|
|
||||||
|
filelist_t *list = find_media_files(v);
|
||||||
|
if(!list) {
|
||||||
|
veejay_msg(VEEJAY_MSG_ERROR, "No usable files found.");
|
||||||
|
sprintf(_s_print_buf, "00000000");
|
||||||
|
}else {
|
||||||
|
|
||||||
|
int len = 1;
|
||||||
|
int i;
|
||||||
|
for( i = 0; i < list->num_files; i ++ ) {
|
||||||
|
len += ( list->files[i] == NULL ? 0 : strlen( list->files[i] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int msg_len = (list->num_files*4) + len - 1;
|
||||||
|
sprintf(_s_print_buf, "%08d", msg_len );
|
||||||
|
|
||||||
|
int tlen=0;
|
||||||
|
for( i = 0; i <list->num_files; i ++ ) {
|
||||||
|
char tmp[1024];
|
||||||
|
if(list->files[i]==NULL)
|
||||||
|
continue;
|
||||||
|
tlen = strlen(list->files[i]);
|
||||||
|
#ifdef STRICT_CHECKING
|
||||||
|
assert( tlen <= sizeof(tmp));
|
||||||
|
#endif
|
||||||
|
snprintf(tmp,sizeof(tmp), "%04d%s",tlen,list->files[i]);
|
||||||
|
|
||||||
|
strcat( _s_print_buf,tmp);
|
||||||
|
}
|
||||||
|
SEND_MSG(v,_s_print_buf);
|
||||||
|
free_media_files(v,list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void vj_event_send_sample_list ( void *ptr, const char format[], va_list ap )
|
void vj_event_send_sample_list ( void *ptr, const char format[], va_list ap )
|
||||||
{
|
{
|
||||||
veejay_t *v = (veejay_t*)ptr;
|
veejay_t *v = (veejay_t*)ptr;
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ void vj_event_disable_audio ( void *ptr, const char format[], va_list ap );
|
|||||||
void vj_event_print_info ( void *ptr, const char format[], va_list ap );
|
void vj_event_print_info ( void *ptr, const char format[], va_list ap );
|
||||||
void vj_event_send_keylist( void *ptr, const char format[], va_list ap );
|
void vj_event_send_keylist( void *ptr, const char format[], va_list ap );
|
||||||
void vj_event_send_tag_list ( void *ptr, const char format[], va_list ap );
|
void vj_event_send_tag_list ( void *ptr, const char format[], va_list ap );
|
||||||
|
void vj_event_send_working_dir(void *ptr, const char format[], va_list ap);
|
||||||
void vj_event_send_sample_list ( void *ptr, const char format[], va_list ap );
|
void vj_event_send_sample_list ( void *ptr, const char format[], va_list ap );
|
||||||
void vj_event_send_log ( void *ptr, const char format[], va_list ap );
|
void vj_event_send_log ( void *ptr, const char format[], va_list ap );
|
||||||
void vj_event_send_chain_list ( void *ptr, const char format[], va_list ap );
|
void vj_event_send_chain_list ( void *ptr, const char format[], va_list ap );
|
||||||
|
|||||||
@@ -1770,11 +1770,22 @@ void vj_init_vevo_events(void)
|
|||||||
0,
|
0,
|
||||||
VIMS_ALLOW_ANY,
|
VIMS_ALLOW_ANY,
|
||||||
NULL );
|
NULL );
|
||||||
|
index_map_[VIMS_WORKINGDIR] = _new_event(
|
||||||
|
"%d",
|
||||||
|
VIMS_WORKINGDIR,
|
||||||
|
"GUI: Get all video files starting in cwd",
|
||||||
|
vj_event_send_working_dir,
|
||||||
|
1,
|
||||||
|
VIMS_ALLOW_ANY,
|
||||||
|
"(unused)",
|
||||||
|
0,
|
||||||
|
NULL );
|
||||||
|
|
||||||
|
|
||||||
index_map_[VIMS_SAMPLE_LIST] = _new_event(
|
index_map_[VIMS_SAMPLE_LIST] = _new_event(
|
||||||
"%d",
|
"%d",
|
||||||
VIMS_SAMPLE_LIST,
|
VIMS_SAMPLE_LIST,
|
||||||
"GUI: Get a list of all samples (unadvised!)",
|
"GUI: Get a list of all samples",
|
||||||
vj_event_send_sample_list,
|
vj_event_send_sample_list,
|
||||||
1,
|
1,
|
||||||
VIMS_ALLOW_ANY,
|
VIMS_ALLOW_ANY,
|
||||||
|
|||||||
@@ -72,6 +72,153 @@ unsigned int vj_get_relative_time()
|
|||||||
return relative;
|
return relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
const char *ext;
|
||||||
|
} filefilters[] = {
|
||||||
|
{ ".avi" },
|
||||||
|
{ ".mov" },
|
||||||
|
{ ".dv" },
|
||||||
|
{ ".edl" },
|
||||||
|
{ ".y4m" },
|
||||||
|
{ NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int is_it_usable(const char *file)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while ( filefilters[i].ext != NULL ) {
|
||||||
|
if(strcasestr( file, filefilters[i].ext ) )
|
||||||
|
return 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *relative_path(filelist_t *filelist, const char *node)
|
||||||
|
{
|
||||||
|
int len = strlen(filelist->working_dir);
|
||||||
|
if( node + len + 1 ) {
|
||||||
|
char *tmp = strdup( node + len + 1);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
return strdup(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_usable_file( filelist_t *filelist, const char *node, const char *filename )
|
||||||
|
{
|
||||||
|
if(!node)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
struct stat l;
|
||||||
|
veejay_memset(&l,0,sizeof(struct stat));
|
||||||
|
#ifdef STRICT_CHECKING
|
||||||
|
assert( filelist != NULL );
|
||||||
|
assert( filelist->num_files >= 0 || filelist->num_files < 1024 );
|
||||||
|
#endif
|
||||||
|
if( lstat( node, &l) < 0 )
|
||||||
|
return 0;
|
||||||
|
if( S_ISLNK( l.st_mode )) {
|
||||||
|
veejay_memset(&l,0,sizeof(struct stat));
|
||||||
|
stat(node, &l);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if( S_ISDIR( l.st_mode ) ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( S_ISREG( l.st_mode ) ) {
|
||||||
|
if( is_it_usable(node)) {
|
||||||
|
if( filelist->num_files < filelist->max_files-1 ) {
|
||||||
|
filelist->files[ filelist->num_files ] =
|
||||||
|
relative_path(filelist,node);
|
||||||
|
filelist->num_files ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dir_selector( const struct dirent *dir )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int find_files( filelist_t *filelist, const char *path )
|
||||||
|
{
|
||||||
|
struct dirent **files;
|
||||||
|
int N = scandir ( path, &files, dir_selector,alphasort );
|
||||||
|
int n;
|
||||||
|
if( N < 0 ) {
|
||||||
|
veejay_msg(VEEJAY_MSG_ERROR, "Invalid path %s",path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( n = 0; n < N; n ++ )
|
||||||
|
{
|
||||||
|
char tmp[2048];
|
||||||
|
if( strcmp( files[n]->d_name, "." ) == 0 ||
|
||||||
|
strcmp( files[n]->d_name, ".." ) == 0 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(tmp,sizeof(tmp), "%s/%s", path,files[n]->d_name );
|
||||||
|
if(is_usable_file( filelist, tmp, files[n]->d_name ) ) { //@recurse
|
||||||
|
find_files( filelist, tmp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( n = 0; n < N; n ++ ) {
|
||||||
|
if( files[n])
|
||||||
|
free(files[n]);
|
||||||
|
}
|
||||||
|
free(files);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
void free_media_files( veejay_t *info, filelist_t *fl )
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
for( n = 0; n < fl->num_files ; n ++ ) {
|
||||||
|
if(fl->files[n] != NULL ) {
|
||||||
|
free(fl->files[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(fl->files);
|
||||||
|
free(fl->working_dir);
|
||||||
|
free(fl);
|
||||||
|
fl = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
filelist_t *find_media_files( veejay_t *info )
|
||||||
|
{
|
||||||
|
char working_dir[2048];
|
||||||
|
|
||||||
|
char *wd = getcwd( working_dir, sizeof(working_dir));
|
||||||
|
|
||||||
|
if( wd == NULL ) {
|
||||||
|
veejay_msg(0, "Strange, current working directory seems to be invalid?");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
filelist_t *fl = (filelist_t*) vj_malloc(sizeof(filelist_t));
|
||||||
|
fl->files = (char**) vj_malloc(sizeof(char*) * 1024 ); //@ 1024 files
|
||||||
|
fl->max_files = 1024;
|
||||||
|
fl->num_files = 0;
|
||||||
|
fl->working_dir = strdup(working_dir);
|
||||||
|
|
||||||
|
int res = find_files( fl, wd );
|
||||||
|
|
||||||
|
if( res == 0 ) {
|
||||||
|
veejay_msg(VEEJAY_MSG_DEBUG, "No files found in %s", wd );
|
||||||
|
free( fl->files );
|
||||||
|
free( fl );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int vj_perform_take_bg(veejay_t *info, VJFrame *frame, int pass)
|
int vj_perform_take_bg(veejay_t *info, VJFrame *frame, int pass)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@@ -501,3 +648,7 @@ int veejay_sprintf( char *s, size_t size, const char *format, ... )
|
|||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,14 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "vj-lib.h"
|
#include "vj-lib.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char **files;
|
||||||
|
char *working_dir;
|
||||||
|
int num_files;
|
||||||
|
int max_files;
|
||||||
|
} filelist_t;
|
||||||
|
|
||||||
#define VEEJAY_FILE_LIMIT (1048576 * 16000)
|
#define VEEJAY_FILE_LIMIT (1048576 * 16000)
|
||||||
int available_diskspace(void);
|
int available_diskspace(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user