Example #1
0
static gboolean
plugin_init (GstPlugin * plugin)
{
  GST_DEBUG_CATEGORY_INIT (ffmpeg_debug, "ffmpeg", 0, "FFmpeg elements");
#ifndef GST_DISABLE_GST_DEBUG

  av_log_set_callback (gst_ffmpeg_log_callback);
#endif

  gst_ffmpeg_init_pix_fmt_info ();

  av_register_all ();

  gst_ffmpegenc_register (plugin);
  gst_ffmpegdec_register (plugin);
  gst_ffmpegdemux_register (plugin);
  gst_ffmpegmux_register (plugin);
  gst_ffmpegdeinterlace_register (plugin);
#if 0
  gst_ffmpegscale_register (plugin);
#endif
#if 0
  gst_ffmpegcsp_register (plugin);
#endif
  gst_ffmpegaudioresample_register (plugin);

  av_register_protocol2 (&gstreamer_protocol, sizeof (URLProtocol));
  av_register_protocol2 (&gstpipe_protocol, sizeof (URLProtocol));

  /* Now we can return the pointer to the newly created Plugin object. */
  return TRUE;
}
Example #2
0
/**
 * ffmpeg_init
 *      Initializes for libavformat.
 *
 * Returns
 *      Function returns nothing.
 */
void ffmpeg_init()
{
    MOTION_LOG(NTC, TYPE_ENCODER, NO_ERRNO, "%s: ffmpeg LIBAVCODEC_BUILD %d"
               " LIBAVFORMAT_BUILD %d", LIBAVCODEC_BUILD, 
               LIBAVFORMAT_BUILD);
    av_register_all();

#if LIBAVCODEC_BUILD > 4680
    av_log_set_callback((void *)ffmpeg_avcodec_log);
    av_log_set_level(AV_LOG_ERROR);
#endif

#if defined FF_API_NEW_AVIO
#else
    /*
     * Copy the functions to use for the append file protocol from the standard
     * file protocol.
     */
    mpeg1_file_protocol.url_read  = file_protocol.url_read;
    mpeg1_file_protocol.url_write = file_protocol.url_write;
    mpeg1_file_protocol.url_seek  = file_protocol.url_seek;
    mpeg1_file_protocol.url_close = file_protocol.url_close;

/* Register the append file protocol. */
#ifdef have_av_register_protocol2
    av_register_protocol2(&mpeg1_file_protocol, sizeof(mpeg1_file_protocol));
#elif defined have_av_register_protocol        
    av_register_protocol(&mpeg1_file_protocol);
#else
#   warning av_register_protocolXXX missing
#endif

#endif // FF_API_NEW_AVIO

}
Example #3
0
bool CAMLPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
{
  try
  {
    CLog::Log(LOGNOTICE, "CAMLPlayer: Opening: %s", file.GetPath().c_str());
    // if playing a file close it first
    // this has to be changed so we won't have to close it.
    if (ThreadHandle())
      CloseFile();

    m_item = file;
    m_options = options;
    m_elapsed_ms  =  0;
    m_duration_ms =  0;

    m_audio_info  = "none";
    m_audio_delay = g_settings.m_currentVideoSettings.m_AudioDelay;

    m_video_info  = "none";
    m_video_width    =  0;
    m_video_height   =  0;
    m_video_fps_numerator = 25;
    m_video_fps_denominator = 1;

    m_subtitle_delay =  0;
    m_subtitle_thread = NULL;

    m_chapter_index  =  0;
    m_chapter_count  =  0;

    m_show_mainvideo = -1;
    m_dst_rect.SetRect(0, 0, 0, 0);

    ClearStreamInfos();

    static URLProtocol vfs_protocol = {
      "vfs",
      CFileURLProtocol::Open,
      CFileURLProtocol::Read,
      CFileURLProtocol::Write,
      CFileURLProtocol::Seek,
      CFileURLProtocol::SeekEx, // url_exseek, an amlogic extension.
      CFileURLProtocol::Close,
    };

    CStdString url = m_item.GetPath();
    if (url.Left(strlen("smb://")).Equals("smb://"))
    {
      // the name string needs to persist 
      static const char *smb_name = "smb";
      vfs_protocol.name = smb_name;
    }
    else if (url.Left(strlen("afp://")).Equals("afp://"))
    {
      // the name string needs to persist 
      static const char *afp_name = "afp";
      vfs_protocol.name = afp_name;
    }
    else if (url.Left(strlen("nfs://")).Equals("nfs://"))
    {
      // the name string needs to persist 
      static const char *nfs_name = "nfs";
      vfs_protocol.name = nfs_name;
    }
    else if (url.Left(strlen("http://")).Equals("http://"))
    {
      // the name string needs to persist 
      static const char *http_name = "xb-http";
      vfs_protocol.name = http_name;
      url = "xb-" + url;
    }
    printf("CAMLPlayer::OpenFile: URL=%s\n", url.c_str());

    if (player_init() != PLAYER_SUCCESS)
    {
      printf("player init failed\n");
      return false;
    }
    printf("player init......\n");

    // must be after player_init
    av_register_protocol2(&vfs_protocol, sizeof(vfs_protocol));

    static play_control_t  play_control;
    memset(&play_control, 0, sizeof(play_control_t));
    // if we do not register a callback,
    // then the libamplayer will free run checking status.
    player_register_update_callback(&play_control.callback_fn, &UpdatePlayerInfo, 1000);
    // leak file_name for now.
    play_control.file_name = (char*)strdup(url.c_str());
    //play_control->nosound   = 1; // if disable audio...,must call this api
    play_control.video_index = -1; //MUST
    play_control.audio_index = -1; //MUST
    play_control.sub_index   = -1; //MUST
    play_control.hassub      =  1;
    play_control.t_pos       = -1;
    play_control.need_start  =  1; // if 0,you can omit player_start_play API.
                                   // just play video/audio immediately.
                                   // if 1,then need call "player_start_play" API;
    //play_control.auto_buffing_enable = 1;
    //play_control.buffing_min        = 0.2;
    //play_control.buffing_middle     = 0.5;
    //play_control.buffing_max        = 0.8;
    //play_control.byteiobufsize      =; // maps to av_open_input_file buffer size
    //play_control.loopbufsize        =;
    //play_control.enable_rw_on_pause =;
    m_aml_state.clear();
    m_aml_state.push_back(0);
    m_pid = player_start(&play_control, 0);
    if (m_pid < 0)
    {
      printf("player start failed! error = %d\n", m_pid);
      return false;
    }

    // setup to spin the busy dialog until we are playing
    m_ready.Reset();

    g_renderManager.PreInit();

    // create the playing thread
    m_StopPlaying = false;
    Create();
    if (!m_ready.WaitMSec(100))
    {
      CGUIDialogBusy *dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY);
      dialog->Show();
      while (!m_ready.WaitMSec(1))
        g_windowManager.ProcessRenderLoop(false);
      dialog->Close();
    }

    // Playback might have been stopped due to some error.
    if (m_bStop || m_StopPlaying)
      return false;

    return true;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s - Exception thrown on open", __FUNCTION__);
    return false;
  }
}
Example #4
0
File: avio.c Project: upsilon/libav
int register_protocol(URLProtocol *protocol)
{
    return av_register_protocol2(protocol, sizeof(struct URLProtocol_compat));
}