Changeset 4056 for pjproject/trunk
- Timestamp:
- Apr 17, 2012 2:48:29 AM (13 years ago)
- Location:
- pjproject/trunk/pjmedia/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ffmpeg_vid_codecs.c
r4049 r4056 594 594 goto on_error; 595 595 596 pjmedia_ffmpeg_add_ref(); 596 597 avcodec_init(); 597 598 avcodec_register_all(); 598 av_log_set_level(AV_LOG_ERROR);599 599 600 600 /* Enum FFMPEG codecs */ … … 855 855 ffmpeg_factory.pool = NULL; 856 856 857 pjmedia_ffmpeg_dec_ref(); 858 857 859 return status; 858 860 } -
pjproject/trunk/pjmedia/src/pjmedia/converter_libswscale.c
r3757 r4056 185 185 { 186 186 libswscale_factory.op = &libswscale_factory_op; 187 pjmedia_ffmpeg_add_ref(); 187 188 return pjmedia_converter_mgr_register_factory(mgr, &libswscale_factory); 188 189 } … … 194 195 { 195 196 PJ_UNUSED_ARG(pool); 197 pjmedia_ffmpeg_dec_ref(); 196 198 return pjmedia_converter_mgr_unregister_factory(mgr, &libswscale_factory, 197 199 PJ_TRUE); -
pjproject/trunk/pjmedia/src/pjmedia/ffmpeg_util.c
r4044 r4056 19 19 #include <pjmedia/types.h> 20 20 #include <pj/errno.h> 21 #include <pj/log.h> 22 #include <pj/string.h> 21 23 22 24 #if PJMEDIA_HAS_LIBAVFORMAT && PJMEDIA_HAS_LIBAVUTIL … … 75 77 static int pjmedia_ffmpeg_ref_cnt; 76 78 79 static void ffmpeg_log_cb(void* ptr, int level, const char* fmt, va_list vl); 80 77 81 void pjmedia_ffmpeg_add_ref() 78 82 { 79 83 if (pjmedia_ffmpeg_ref_cnt++ == 0) { 84 av_log_set_level(AV_LOG_ERROR); 85 av_log_set_callback(&ffmpeg_log_cb); 80 86 av_register_all(); 81 87 } … … 90 96 if (pjmedia_ffmpeg_ref_cnt < 0) pjmedia_ffmpeg_ref_cnt = 0; 91 97 } 98 99 100 static void ffmpeg_log_cb(void* ptr, int level, const char* fmt, va_list vl) 101 { 102 const char *LOG_SENDER = "ffmpeg"; 103 enum { LOG_LEVEL = 5 }; 104 char buf[100]; 105 int bufsize = sizeof(buf), len; 106 pj_str_t fmt_st; 107 108 /* Custom callback needs to filter log level by itself */ 109 if (level > av_log_get_level()) 110 return; 111 112 /* Add original ffmpeg sender to log format */ 113 if (ptr) { 114 AVClass* avc = *(AVClass**)ptr; 115 len = pj_ansi_snprintf(buf, bufsize, "%s: ", avc->item_name(ptr)); 116 bufsize -= len; 117 } 118 119 /* Copy original log format */ 120 len = pj_ansi_strlen(fmt); 121 if (len > bufsize-1) 122 len = bufsize-1; 123 pj_memcpy(buf+sizeof(buf)-bufsize, fmt, len); 124 bufsize -= len; 125 126 /* Trim log format */ 127 pj_strset(&fmt_st, buf, sizeof(buf)-bufsize); 128 pj_strrtrim(&fmt_st); 129 buf[fmt_st.slen] = '\0'; 130 131 pj_log(LOG_SENDER, LOG_LEVEL, buf, vl); 132 } 133 92 134 93 135 pj_status_t pjmedia_format_id_to_PixelFormat(pjmedia_format_id fmt_id,
Note: See TracChangeset
for help on using the changeset viewer.