| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
#ifdef HAVE_CONFIG_H |
|---|
| 28 |
# include "config.h" |
|---|
| 29 |
#endif |
|---|
| 30 |
|
|---|
| 31 |
#include <vlc_common.h> |
|---|
| 32 |
#include <vlc_codec.h> |
|---|
| 33 |
|
|---|
| 34 |
#ifdef HAVE_UNISTD_H |
|---|
| 35 |
# include <unistd.h> |
|---|
| 36 |
#elif defined( WIN32 ) && !defined( UNDER_CE ) |
|---|
| 37 |
# include <io.h> |
|---|
| 38 |
#endif |
|---|
| 39 |
#ifdef HAVE_SYS_TYPES_H |
|---|
| 40 |
# include <sys/types.h> |
|---|
| 41 |
#endif |
|---|
| 42 |
#ifdef HAVE_SYS_STAT_H |
|---|
| 43 |
# include <sys/stat.h> |
|---|
| 44 |
#endif |
|---|
| 45 |
#ifdef HAVE_FCNTL_H |
|---|
| 46 |
# include <fcntl.h> |
|---|
| 47 |
#endif |
|---|
| 48 |
|
|---|
| 49 |
#include <limits.h> |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
#include "dummy.h" |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
struct decoder_sys_t |
|---|
| 58 |
{ |
|---|
| 59 |
int i_fd; |
|---|
| 60 |
}; |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ); |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
int OpenDecoder ( vlc_object_t *p_this ) |
|---|
| 71 |
{ |
|---|
| 72 |
decoder_t *p_dec = (decoder_t*)p_this; |
|---|
| 73 |
decoder_sys_t *p_sys; |
|---|
| 74 |
char psz_file[ PATH_MAX ]; |
|---|
| 75 |
vlc_value_t val; |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
if( ( p_dec->p_sys = p_sys = |
|---|
| 79 |
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) |
|---|
| 80 |
{ |
|---|
| 81 |
msg_Err( p_dec, "out of memory" ); |
|---|
| 82 |
return VLC_EGENERIC; |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
snprintf( psz_file, sizeof( psz_file), "stream.%p", p_dec ); |
|---|
| 86 |
|
|---|
| 87 |
#ifndef UNDER_CE |
|---|
| 88 |
var_Create( p_dec, "dummy-save-es", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); |
|---|
| 89 |
var_Get( p_dec, "dummy-save-es", &val ); |
|---|
| 90 |
if( val.b_bool ) |
|---|
| 91 |
{ |
|---|
| 92 |
p_sys->i_fd = open( psz_file, O_WRONLY | O_CREAT | O_TRUNC, 00644 ); |
|---|
| 93 |
|
|---|
| 94 |
if( p_sys->i_fd == -1 ) |
|---|
| 95 |
{ |
|---|
| 96 |
msg_Err( p_dec, "cannot create `%s'", psz_file ); |
|---|
| 97 |
return VLC_EGENERIC; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
msg_Dbg( p_dec, "dumping stream to file `%s'", psz_file ); |
|---|
| 101 |
} |
|---|
| 102 |
else |
|---|
| 103 |
#endif |
|---|
| 104 |
{ |
|---|
| 105 |
p_sys->i_fd = -1; |
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
p_dec->pf_decode_video = (picture_t *(*)(decoder_t *, block_t **)) |
|---|
| 110 |
DecodeBlock; |
|---|
| 111 |
p_dec->pf_decode_audio = (aout_buffer_t *(*)(decoder_t *, block_t **)) |
|---|
| 112 |
DecodeBlock; |
|---|
| 113 |
p_dec->pf_decode_sub = (subpicture_t *(*)(decoder_t *, block_t **)) |
|---|
| 114 |
DecodeBlock; |
|---|
| 115 |
|
|---|
| 116 |
return VLC_SUCCESS; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) |
|---|
| 125 |
{ |
|---|
| 126 |
decoder_sys_t *p_sys = p_dec->p_sys; |
|---|
| 127 |
block_t *p_block; |
|---|
| 128 |
|
|---|
| 129 |
if( !pp_block || !*pp_block ) return NULL; |
|---|
| 130 |
p_block = *pp_block; |
|---|
| 131 |
|
|---|
| 132 |
if( p_sys->i_fd >= 0 && p_block->i_buffer ) |
|---|
| 133 |
{ |
|---|
| 134 |
#ifndef UNDER_CE |
|---|
| 135 |
write( p_sys->i_fd, p_block->p_buffer, p_block->i_buffer ); |
|---|
| 136 |
#endif |
|---|
| 137 |
|
|---|
| 138 |
msg_Dbg( p_dec, "dumped %zu bytes", p_block->i_buffer ); |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
block_Release( p_block ); |
|---|
| 142 |
return NULL; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
void CloseDecoder ( vlc_object_t *p_this ) |
|---|
| 149 |
{ |
|---|
| 150 |
decoder_t *p_dec = (decoder_t *)p_this; |
|---|
| 151 |
decoder_sys_t *p_sys = p_dec->p_sys; |
|---|
| 152 |
|
|---|
| 153 |
#ifndef UNDER_CE |
|---|
| 154 |
if( p_sys->i_fd >= 0 ) close( p_sys->i_fd ); |
|---|
| 155 |
#endif |
|---|
| 156 |
|
|---|
| 157 |
free( p_sys ); |
|---|
| 158 |
} |
|---|