Module: Vlc
Constant Summary collapse
- VLC_FUNCTIONS_MAP =
Fiddle’s default ‘extern’ stores all methods into local variable ‘@func_map’, that makes difficult to ‘include Vlc’. So override it and replace ‘@func_map’ into ‘VLC_FUNCTIONS_MAP’. Ref.: /lib/ruby/2.0.0/fiddle/import.rb Borrowed from github.com/vaiorabbit/ruby-opengl
{}
- LIBVLC_TRACK_UNKNOWN =
libvlc_track_type_t
-1
- LIBVLC_TRACK_AUDIO =
0
- LIBVLC_TRACK_VIDEO =
1
- LIBVLC_TRACK_TEXT =
2
- Audio_track =
struct [ 'unsigned int i_channels', 'unsigned int i_rate' ]
- Video_track =
struct [ 'unsigned int i_height', 'unsigned int i_width', 'unsigned int i_sar_num', 'unsigned int i_sar_den', 'unsigned int i_frame_rate_num', 'unsigned int i_frame_rate_den' ]
- Subtitle_track =
struct ['char *psz_encoding']
- Media_track =
struct [ 'unsigned int i_codec', 'unsigned int i_original_fourcc', 'int i_id', 'int i_type', # libvlc_track_type_t # Codec specific 'int i_profile', 'int i_level', # a void pointer representing an union 'void* kind', 'unsigned int i_bitrate', 'char *psz_language', 'char *psz_description' ]
- Media_stats =
struct [ #/* Input */ 'int i_read_bytes', 'float f_input_bitrate', #/* Demux */ 'int i_demux_read_bytes', 'float f_demux_bitrate', 'int i_demux_corrupted', 'int i_demux_discontinuity', #/* Decoders */ 'int i_decoded_video', 'int i_decoded_audio', #/* Video Output */ 'int i_displayed_pictures', 'int i_lost_pictures', #/* Audio output */ 'int i_played_abuffers', 'int i_lost_abuffers', #/* Stream output */ 'int i_sent_packets', 'int i_sent_bytes', 'float f_send_bitrate' ]
- @@vlc_import_done =
false
Class Method Summary collapse
- .extern(signature, *opts) ⇒ Object
- .import_symbols ⇒ Object
-
.load_lib ⇒ Object
Load native library.
- .vlc_import_done ⇒ Object
Class Method Details
.extern(signature, *opts) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shoes/videoffi.rb', line 12 def self.extern(signature, *opts) symname, ctype, argtype = parse_signature(signature, @type_alias) opt = (opts) f = import_function(symname, ctype, argtype, opt[:call_type]) name = symname.gsub(/@.+/,'') VLC_FUNCTIONS_MAP[name] = f begin /^(.+?):(\d+)/ =~ caller.first file, line = $1, $2.to_i rescue file, line = __FILE__, __LINE__+3 end args_str="*args" module_eval(<<-EOS, file, line) def #{name}(*args, &block) VLC_FUNCTIONS_MAP['#{name}'].call(*args,&block) end EOS module_function(name) f end |
.import_symbols ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/shoes/videoffi.rb', line 99 def self.import_symbols typealias "uint32_t", "unsigned int" typealias "libvlc_time_t", "long long" typealias "libvlc_track_type_t", "int" extern 'libvlc_instance_t * libvlc_new( int , const char* )' extern 'void libvlc_release( libvlc_instance_t* )' extern 'const char* libvlc_errmsg(void)' ### Media extern 'libvlc_media_t* libvlc_media_new_path(libvlc_instance_t*, const char* )' extern 'libvlc_media_t* libvlc_media_new_location(libvlc_instance_t*, const char* )' extern 'void libvlc_media_parse( libvlc_media_t* )' extern 'int libvlc_media_is_parsed( libvlc_media_t* )' extern 'unsigned int libvlc_media_tracks_get( libvlc_media_t*, libvlc_media_track_t*** )' extern 'void libvlc_media_tracks_release( libvlc_media_track_t**, unsigned int )' extern 'void libvlc_media_release( libvlc_media_t* )' extern 'int libvlc_media_get_stats( libvlc_media_t*, struct libvlc_media_stats_t* )' ### Media player extern 'libvlc_media_player_t* libvlc_media_player_new( libvlc_instance_t* )' extern 'void libvlc_media_player_release( libvlc_media_player_t* )' # extern 'void libvlc_media_player_set_media( libvlc_media_player_t*, libvlc_media_t* )' # extern 'int libvlc_media_player_play( libvlc_media_player_t* )' # extern 'void libvlc_media_player_stop( libvlc_media_player_t* )' # extern 'void libvlc_media_player_pause( libvlc_media_player_t* )' # extern 'int libvlc_media_player_is_playing( libvlc_media_player_t*)' ## Platform specific extern 'uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t*)' extern 'void libvlc_media_player_set_xwindow( libvlc_media_player_t*, uint32_t )' extern 'void* libvlc_media_player_get_hwnd( libvlc_media_player_t* )' extern 'void libvlc_media_player_set_hwnd( libvlc_media_player_t*, void* )' extern 'void* libvlc_media_player_get_nsobject( libvlc_media_player_t* )' extern 'void libvlc_media_player_set_nsobject( libvlc_media_player_t*, void* )' extern 'libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t* )' extern 'void libvlc_media_player_set_time(libvlc_media_player_t*, libvlc_time_t )' extern 'libvlc_time_t libvlc_media_player_get_length( libvlc_media_player_t* )' extern 'float libvlc_media_player_get_position( libvlc_media_player_t* )' extern 'void libvlc_media_player_set_position( libvlc_media_player_t*, float )' ### Media List extern 'libvlc_media_list_t* libvlc_media_list_new( libvlc_instance_t* )' extern 'void libvlc_media_list_release( libvlc_media_list_t* )' extern 'int libvlc_media_list_add_media( libvlc_media_list_t*, libvlc_media_t* )' extern 'int libvlc_media_list_remove_index( libvlc_media_list_t*, int )' extern 'int libvlc_media_list_count( libvlc_media_list_t* )' extern 'void libvlc_media_list_lock( libvlc_media_list_t* )' extern 'void libvlc_media_list_unlock( libvlc_media_list_t* )' ### Media List Player extern 'libvlc_media_list_player_t* libvlc_media_list_player_new(libvlc_instance_t* )' extern 'void libvlc_media_list_player_release( libvlc_media_list_player_t* )' # Not avalaible in vlc 2.2.0 # extern 'libvlc_media_player_t* libvlc_media_list_player_get_media_player( libvlc_media_list_player_t* )' extern 'void libvlc_media_list_player_set_media_player( libvlc_media_list_player_t*, libvlc_media_player_t* )' extern 'void libvlc_media_list_player_set_media_list( libvlc_media_list_player_t*, libvlc_media_list_t* )' extern 'int libvlc_media_list_player_play( libvlc_media_list_player_t* )' extern 'void libvlc_media_list_player_stop( libvlc_media_list_player_t* )' extern 'void libvlc_media_list_player_pause( libvlc_media_list_player_t* )' extern 'int libvlc_media_list_player_is_playing( libvlc_media_list_player_t* )' extern 'int libvlc_media_list_player_next( libvlc_media_list_player_t* )' extern 'int libvlc_media_list_player_previous( libvlc_media_list_player_t* )' extern 'int libvlc_media_list_player_play_item_at_index( libvlc_media_list_player_t*, int )' extern 'int libvlc_media_list_player_play_item( libvlc_media_list_player_t*, libvlc_media_t* )' ### Audio controls extern 'int libvlc_audio_get_volume( libvlc_media_player_t* )' extern 'int libvlc_audio_set_volume( libvlc_media_player_t*, int )' ### Video Controls extern 'int libvlc_video_get_size( libvlc_media_player_t*, unsigned int, unsigned int*, unsigned int* )' # import some platform specific symbols unless RUBY_PLATFORM =~ /darwin/ extern 'void libvlc_video_set_mouse_input( libvlc_media_player_t *, unsigned int )' extern 'void libvlc_video_set_key_input( libvlc_media_player_t *, unsigned int )' end @@vlc_import_done = true end |
.load_lib ⇒ Object
Load native library.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/shoes/videoffi.rb', line 183 def self.load_lib if ENV['VLC_APP_PATH'] vlcpath = ENV['VLC_APP_PATH'] Dir.chdir(File.dirname(vlcpath)) do #puts "VLC opening with ENV: #{vlcpath}" begin dlload(File.basename(vlcpath)) rescue upraise "Sorry, #{vlcpath} doesn't load - is it correct" end end else upraise "I can't find 'VLC_APP_PATH' environment variable.\n" \ "Please check with the Cobbler ('Maintain Shoes' at startup splash)" end # do a version check to make sure it is 2.1 or 2.2 extern 'const char* libvlc_get_version()' versionstr = libvlc_get_version().to_s version = versionstr[/\d.\d/] verno = version.to_f if verno < 2.1 upraise "You need a newer VLC: 2.1 or better" end info "using VLC: #{versionstr}" import_symbols() # just in case ... other functions in Fiddle::Importer are using it # The variable is declared in 'dlload' @func_map = VLC_FUNCTIONS_MAP end |
.vlc_import_done ⇒ Object
216 217 218 |
# File 'lib/shoes/videoffi.rb', line 216 def self.vlc_import_done @@vlc_import_done end |