Changeset 1193:58278fd087fd in mediastreamer2


Ignore:
Timestamp:
Nov 12, 2010 2:12:28 PM (3 years ago)
Author:
Simon Morlat <simon.morlat@…>
Branch:
default
Message:

rework msandroiddisplay filter to be included statically

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • build/android/Android.mk

    r1190 r1193  
    109109        rfc3984.c \ 
    110110        mire.c \ 
    111         videostream.c  
     111        videostream.c \ 
     112        layouts.c \ 
     113        android-display.c 
    112114 
    113115endif 
     
    152154 
    153155 
    154  
    155156include $(BUILD_STATIC_LIBRARY) 
    156  
    157 include $(CLEAR_VARS) 
    158  
    159 LOCAL_MODULE := msandroiddisplay 
    160  
    161 LOCAL_SRC_FILES := android-display.c 
    162  
    163 LOCAL_C_INCLUDES += \ 
    164         $(MEDIASTREAMER2_INCLUDES) 
    165  
    166 LOCAL_CFLAGS += \ 
    167         -UHAVE_CONFIG_H \ 
    168         -include $(LOCAL_PATH)/../build/android/libmediastreamer2_AndroidConfig.h \ 
    169         -D_POSIX_SOURCE 
    170  
    171 LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 
    172  
    173 include $(BUILD_SHARED_LIBRARY) 
    174157 
    175158 
    176159 
     160 
  • src/android-display.c

    r1192 r1193  
    2525#include <android/bitmap.h> 
    2626#include <jni.h> 
     27#include <dlfcn.h> 
    2728 
    2829/*defined in msandroid.cpp*/ 
     
    4142}AndroidDisplay; 
    4243 
     44 
     45static int (*sym_AndroidBitmap_getInfo)(JNIEnv *env,jobject bitmap, AndroidBitmapInfo *bmpinfo)=NULL; 
     46static int (*sym_AndroidBitmap_lockPixels)(JNIEnv *env, jobject bitmap, void **pixels)=NULL; 
     47static int (*sym_AndroidBitmap_unlockPixels)(JNIEnv *env, jobject bitmap)=NULL; 
     48 
    4349static void android_display_init(MSFilter *f){ 
    4450        AndroidDisplay *ad=(AndroidDisplay*)ms_new0(AndroidDisplay,1); 
     
    116122                                        } 
    117123                                } 
    118                                 if (AndroidBitmap_lockPixels(ad->jenv,ad->jbitmap,&pixels)==0){ 
     124                                if (sym_AndroidBitmap_lockPixels(ad->jenv,ad->jbitmap,&pixels)==0){ 
    119125                                        dest.planes[0]=(uint8_t*)pixels+(vrect.y*ad->bmpinfo.stride)+(vrect.x*2); 
    120126                                        dest.strides[0]=ad->bmpinfo.stride; 
    121127                                        ms_sws_scale (ad->sws,pic.planes,pic.strides,0,pic.h,dest.planes,dest.strides); 
    122                                         AndroidBitmap_unlockPixels(ad->jenv,ad->jbitmap); 
     128                                        sym_AndroidBitmap_unlockPixels(ad->jenv,ad->jbitmap); 
    123129                                }else{ 
    124130                                        ms_error("AndroidBitmap_lockPixels() failed !"); 
     
    151157        ad->jbitmap=(*jenv)->CallObjectMethod(jenv,window,ad->get_bitmap_id); 
    152158        ad->android_video_window=window; 
    153         err=AndroidBitmap_getInfo(jenv,ad->jbitmap,&ad->bmpinfo); 
     159        err=sym_AndroidBitmap_getInfo(jenv,ad->jbitmap,&ad->bmpinfo); 
    154160        if (err!=0){ 
    155161                ms_error("AndroidBitmap_getInfo() failed."); 
     
    182188 
    183189void libmsandroiddisplay_init(void){ 
    184         ms_filter_register(&ms_android_display_desc); 
    185 } 
    186  
    187  
     190        /*See if we can use AndroidBitmap_* symbols (only since android 2.2 normally)*/ 
     191        void *handle=dlopen("libjnigraphics.so",RTLD_LAZY); 
     192        if (handle!=NULL){ 
     193                sym_AndroidBitmap_getInfo=dlsym(handle,"AndroidBitmap_getInfo"); 
     194                sym_AndroidBitmap_lockPixels=dlsym(handle,"AndroidBitmap_lockPixels"); 
     195                sym_AndroidBitmap_unlockPixels=dlsym(handle,"AndroidBitmap_unlockPixels"); 
     196 
     197                if (sym_AndroidBitmap_getInfo==NULL || sym_AndroidBitmap_lockPixels==NULL 
     198                        || sym_AndroidBitmap_unlockPixels==NULL){ 
     199                        ms_warning("AndroidBitmap not available."); 
     200                }else{ 
     201                        ms_filter_register(&ms_android_display_desc); 
     202                        ms_message("MSAndroidDisplay registered."); 
     203                } 
     204        }else ms_warning("libjnigraphics.so cannot be loaded."); 
     205} 
     206 
     207 
  • src/mscommon.c

    r1166 r1193  
    2323 
    2424extern void __register_ffmpeg_encoders_if_possible(void); 
     25extern void libmsandroiddisplay_init(void); 
    2526 
    2627#include "mediastreamer2/mscommon.h" 
     
    596597        ms_load_plugins(PACKAGE_PLUGINS_DIR); 
    597598#endif 
     599 
     600#if defined(ANDROID) && defined (VIDEO_ENABLED) 
     601        libmsandroiddisplay_init(); 
     602#endif 
    598603        ms_message("ms_init() done"); 
    599604} 
Note: See TracChangeset for help on using the changeset viewer.