]> granicus.if.org Git - handbrake/commitdiff
Add a second hb_init for dylib call, some languages don't see the macros.
authorprigaux <pri@nopapers.org>
Tue, 6 Feb 2007 09:55:13 +0000 (09:55 +0000)
committerprigaux <pri@nopapers.org>
Tue, 6 Feb 2007 09:55:13 +0000 (09:55 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/MediaFork_0.8.0@263 b64f7644-9d1e-0410-96f1-a4d463321fa5

libmediafork/mediafork.c
libmediafork/mediafork.h

index 9f073b7a0bc563e4e26f86d848b35c1176b5e104..6eb115fd89cdca4cfaea119fbb229591600815d7 100644 (file)
@@ -124,6 +124,96 @@ hb_handle_t * hb_init_real( int verbose, int update_check )
     return h;
 }
 
+/**
+ * libhb initialization routine.
+ * This version is to use when calling the dylib, the macro hb_init isn't available from a dylib call!
+ * @param verbose HB_DEBUG_NONE or HB_DEBUG_ALL.
+ * @param update_check signals libhb to check for updated version from HandBrake website.
+ * @return Handle to hb_handle_t for use on all subsequent calls to libhb.
+ */
+hb_handle_t * hb_init_dl( int verbose, int update_check )
+{
+    hb_handle_t * h = calloc( sizeof( hb_handle_t ), 1 );
+    uint64_t      date;
+
+    /* See hb_log() in common.c */
+    if( verbose > HB_DEBUG_NONE )
+    {
+        putenv( "HB_DEBUG=1" );
+               av_log_set_level(AV_LOG_DEBUG);
+    }
+
+    /* Check for an update on the website if asked to */
+    h->build = -1;
+
+    if( update_check )
+    {
+        hb_log( "hb_init: checking for updates" );
+        date             = hb_get_date();
+        h->update_thread = hb_update_init( &h->build, h->version );
+
+        for( ;; )
+        {
+            if( hb_thread_has_exited( h->update_thread ) )
+            {
+                /* Immediate success or failure */
+                hb_thread_close( &h->update_thread );
+                break;
+            }
+            if( hb_get_date() > date + 1000 )
+            {
+                /* Still nothing after one second. Connection problem,
+                   let the thread die */
+                hb_log( "hb_init: connection problem, not waiting for "
+                        "update_thread" );
+                break;
+            }
+            hb_snooze( 500 );
+        }
+    }
+
+    /* CPU count detection */
+    hb_log( "hb_init: checking cpu count" );
+    h->cpu_count = hb_get_cpu_count();
+
+    h->list_title = hb_list_init();
+    h->jobs       = hb_list_init();
+
+    h->state_lock  = hb_lock_init();
+    h->state.state = HB_STATE_IDLE;
+
+    h->pause_lock = hb_lock_init();
+
+    /* libavcodec */
+    avcodec_init();
+    register_avcodec( &mpeg4_encoder );
+    register_avcodec( &mp2_decoder );
+    register_avcodec( &ac3_encoder );
+
+    /* Start library thread */
+    hb_log( "hb_init: starting libhb thread" );
+    h->die         = 0;
+    h->main_thread = hb_thread_init( "libhb", thread_func, h,
+                                     HB_NORMAL_PRIORITY );
+
+    hb_register( &hb_sync ); 
+       hb_register( &hb_decmpeg2 ); 
+       hb_register( &hb_decsub ); 
+       hb_register( &hb_render ); 
+       hb_register( &hb_encavcodec ); 
+       hb_register( &hb_encxvid ); 
+       hb_register( &hb_encx264 ); 
+       hb_register( &hb_deca52 ); 
+       hb_register( &hb_decavcodec ); 
+       hb_register( &hb_declpcm ); 
+       hb_register( &hb_encfaac ); 
+       hb_register( &hb_enclame ); 
+       hb_register( &hb_encvorbis ); 
+       
+       return h;
+}
+
+
 /**
  * Returns current version of libhb.
  * @param h Handle to hb_handle_t.
index 6e17b86130976381fac51b1da80afa680f9308c8..8b5d4696a4bb7cc8ce147d0604670d5904ae0471 100644 (file)
@@ -14,6 +14,7 @@ extern "C" {
 #define HB_DEBUG_ALL  1
 void          hb_register( hb_work_object_t * );
 hb_handle_t * hb_init_real( int verbose, int update_check );
+hb_handle_t * hb_init_dl ( int verbose, int update_check ); // hb_init for use with dylib 
 
 #define hb_init(v,u) \
 hb_init_real( v, u ); \