ifo.c
Upload User: kjfoods
Upload Date: 2020-07-06
Package Size: 29949k
Code Size: 4k
Category:

midi program

Development Platform:

Unix_Linux

  1. /*****************************************************************************
  2.  * ifo.c: Dummy ifo demux to enable opening DVDs rips by double cliking on VIDEO_TS.IFO
  3.  *****************************************************************************
  4.  * Copyright (C) 2007 the VideoLAN team
  5.  * $Id: a4ede1f6d809d20d7fd1f37fc97246da9367330f $
  6.  *
  7.  * Authors: Antoine Cellerier <dionoea @t videolan d.t org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  22.  *****************************************************************************/
  23. /*****************************************************************************
  24.  * Preamble
  25.  *****************************************************************************/
  26. #ifdef HAVE_CONFIG_H
  27. # include "config.h"
  28. #endif
  29. #include <vlc_common.h>
  30. #include <vlc_demux.h>
  31. #include "playlist.h"
  32. /*****************************************************************************
  33.  * Local prototypes
  34.  *****************************************************************************/
  35. static int Demux( demux_t *p_demux);
  36. static int Control( demux_t *p_demux, int i_query, va_list args );
  37. /*****************************************************************************
  38.  * Import_IFO: main import function
  39.  *****************************************************************************/
  40. int Import_IFO( vlc_object_t *p_this )
  41. {
  42.     demux_t *p_demux = (demux_t *)p_this;
  43.     char *psz_file = p_demux->psz_path + strlen( p_demux->psz_path )
  44.                      - strlen( "VIDEO_TS.IFO" );
  45.     /* Valid filenamed are :
  46.      *  - VIDEO_TS.IFO
  47.      *  - VTS_XX_X.IFO where X are digits
  48.      */
  49.     if( strlen( p_demux->psz_path ) > strlen( "VIDEO_TS.IFO" )
  50.         && ( !strcasecmp( psz_file, "VIDEO_TS.IFO" )
  51.         || (!strncasecmp( psz_file, "VTS_", 4 )
  52.         && !strcasecmp( psz_file + strlen( "VTS_00_0" ) , ".IFO" ) ) ) )
  53.     {
  54.         int i_peek;
  55.         const uint8_t *p_peek;
  56.         i_peek = stream_Peek( p_demux->s, &p_peek, 8 );
  57.         if( i_peek != 8 || memcmp( p_peek, "DVDVIDEO", 8 ) )
  58.             return VLC_EGENERIC;
  59.     }
  60.     else
  61.         return VLC_EGENERIC;
  62. //    STANDARD_DEMUX_INIT_MSG( "found valid VIDEO_TS.IFO" )
  63.     p_demux->pf_control = Control;
  64.     p_demux->pf_demux = Demux;
  65.     return VLC_SUCCESS;
  66. }
  67. /*****************************************************************************
  68.  * Deactivate: frees unused data
  69.  *****************************************************************************/
  70. void Close_IFO( vlc_object_t *p_this )
  71. {
  72.     VLC_UNUSED(p_this);
  73. }
  74. static int Demux( demux_t *p_demux )
  75. {
  76.     char *psz_url = NULL;
  77.     size_t len = 0;
  78.     input_item_t *p_input;
  79.     INIT_PLAYLIST_STUFF;
  80.     len = strlen( "dvd://" ) + strlen( p_demux->psz_path )
  81.           - strlen( "VIDEO_TS.IFO" );
  82.     psz_url = (char *)malloc( len+1 );
  83.     snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path );
  84.     p_input = input_item_New( p_demux, psz_url, psz_url );
  85.     input_item_AddSubItem( p_current_input, p_input );
  86.     vlc_gc_decref( p_input );
  87.     HANDLE_PLAY_AND_RELEASE;
  88.     return 0; /* Needed for correct operation of go back */
  89. }
  90. static int Control( demux_t *p_demux, int i_query, va_list args )
  91. {
  92.     VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args);
  93.     return VLC_EGENERIC;
  94. }