[vlc-commits] modules: allow '-' in module filenames

2015-04-01 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Mar 31 11:20:53 
2015 +| [c7e2d546755edb533bf5b5bf0ca7726d92b2b92a] | committer: 
Jean-Baptiste Kempf

modules: allow '-' in module filenames

In include/vlc_plugin.h, CONCATENATE was failing due to an unexpected '-'
character.

This fixes build with static modules.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c7e2d546755edb533bf5b5bf0ca7726d92b2b92a
---

 modules/common.am |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/common.am b/modules/common.am
index c3b3f8e..9ac2929 100644
--- a/modules/common.am
+++ b/modules/common.am
@@ -15,7 +15,7 @@ CLEANFILES = $(BUILT_SOURCES)
 LTLIBVLCCORE = $(top_builddir)/src/libvlccore.la
 
 # Module name from object or executable file name.
-MODULE_NAME = $$(p=$@; p=$${p\#\#*/}; p=$${p\#lib}; p=$${p%_plugin*}; 
p=$${p%.lo}; echo $$p)
+MODULE_NAME = $$(p=$@; p=$${p\#\#*/}; p=$${p\#lib}; p=$${p%_plugin*}; 
p=$${p//-/\_}; p=$${p%.lo}; echo $$p)
 
 AM_CPPFLAGS = -DMODULE_STRING=\$(MODULE_NAME)\
 if HAVE_DYNAMIC_PLUGINS

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: fix crash

2015-03-05 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Mar  5 17:17:50 
2015 +0100| [d693e502b56d6845ddaa4703d9c8092edbcd0349] | committer: 
Jean-Baptiste Kempf

audiotrack: fix crash

Create the thread after p_aout-sys is set.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d693e502b56d6845ddaa4703d9c8092edbcd0349
---

 modules/audio_output/audiotrack.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index e21e31e..7ac723a 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -1211,6 +1211,16 @@ Open( vlc_object_t *obj )
 vlc_cond_init( p_sys-cond );
 TAILQ_INIT( p_sys-thread_cmd_queue );
 
+p_aout-sys = p_sys;
+p_aout-start = Start;
+p_aout-stop = Stop;
+p_aout-play = Play;
+p_aout-pause = Pause;
+p_aout-flush = Flush;
+p_aout-time_get = TimeGet;
+
+aout_SoftVolumeInit( p_aout );
+
 /* create JNIThread */
 p_sys-b_thread_run = true;
 if( vlc_clone( p_sys-thread,
@@ -1222,16 +1232,6 @@ Open( vlc_object_t *obj )
 return VLC_EGENERIC;
 }
 
-p_aout-sys = p_sys;
-p_aout-start = Start;
-p_aout-stop = Stop;
-p_aout-play = Play;
-p_aout-pause = Pause;
-p_aout-flush = Flush;
-p_aout-time_get = TimeGet;
-
-aout_SoftVolumeInit( p_aout );
-
 return VLC_SUCCESS;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: Fix deadlock with Android 4.4.2, 4.4.3 and 4.4.4

2015-03-05 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Mar  5 19:03:33 
2015 +0100| [aa1daf01062dcd5fa427fa14c678d558930b7651] | committer: 
Jean-Baptiste Kempf

audiotrack: Fix deadlock with Android 4.4.2, 4.4.3 and 4.4.4

see https://code.google.com/p/android/issues/detail?id=65807
see https://code.google.com/p/android/issues/detail?id=70877

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa1daf01062dcd5fa427fa14c678d558930b7651
---

 modules/audio_output/audiotrack.c |   42 ++---
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index a8eb020..a2419ac 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -65,6 +65,7 @@ struct aout_sys_t {
 uint32_t i_max_audiotrack_samples;
 mtime_t i_play_time; /* time when play was called */
 bool b_audiotrack_exception; /* true if audiotrack throwed an exception */
+int i_audiotrack_stuck_count;
 
 /* JNIThread control */
 vlc_mutex_t mutex;
@@ -265,10 +266,8 @@ InitJNIFields( audio_output_t *p_aout )
 } else
 GET_ID( GetMethodID, AudioTrack.write, write, ([BII)I, true );
 
-#ifdef AUDIOTRACK_USE_TIMESTAMP
 GET_ID( GetMethodID, AudioTrack.getTimestamp,
 getTimestamp, (Landroid/media/AudioTimestamp;)Z, false );
-#endif
 GET_ID( GetMethodID, AudioTrack.getPlaybackHeadPosition,
 getPlaybackHeadPosition, ()I, true );
 
@@ -617,6 +616,7 @@ JNIThread_Start( JNIEnv *env, audio_output_t *p_aout )
 goto error;
 }
 
+#ifdef AUDIOTRACK_USE_TIMESTAMP
 if( jfields.AudioTimestamp.clazz )
 {
 /* create AudioTimestamp object */
@@ -630,6 +630,7 @@ JNIThread_Start( JNIEnv *env, audio_output_t *p_aout )
 if( !p_sys-p_audioTimestamp )
 goto error;
 }
+#endif
 
 p_sys-fmt.i_rate = i_rate;
 
@@ -696,7 +697,25 @@ JNIThread_Write( JNIEnv *env, audio_output_t *p_aout, 
block_t *p_buffer )
 
 /* check if audiotrack buffer is not full before writing on it. */
 if( i_samples_pending = p_sys-i_max_audiotrack_samples )
-return 0;
+{
+
+/* HACK: AudioFlinger can drop frames without notifying us and there is
+ * no way to know it. It it happens, i_audiotrack_pos won't move and
+ * the current code will be stuck because it'll assume that audiotrack
+ * internal buffer is full when it's not. It can happen only after
+ * Android 4.4.2 if we send frames too quickly. This HACK is just an
+ * other precaution since it shouldn't happen anymore thanks to the
+ * HACK in JNIThread_Play */
+
+p_sys-i_audiotrack_stuck_count++;
+if( p_sys-i_audiotrack_stuck_count  100 )
+{
+msg_Warn( p_aout, AudioFlinger underrun, force write );
+i_samples_pending = 0;
+p_sys-i_audiotrack_stuck_count = 0;
+}
+} else
+p_sys-i_audiotrack_stuck_count = 0;
 i_samples = __MIN( p_sys-i_max_audiotrack_samples - i_samples_pending,
p_buffer-i_nb_samples );
 
@@ -732,10 +751,8 @@ JNIThread_Write( JNIEnv *env, audio_output_t *p_aout, 
block_t *p_buffer )
 }
 
 /**
- * JNIThread_Write doesn't always work on Lollipop. Probably because audiotrack
- * buffer size is bigger than the one we pass in ctor arguments (and there is
- * no way to know it). It's not an issue since there is a new write method that
- * is non blocking.
+ * Non blocking write function for Lollipop and after.
+ * It calls a new write method with WRITE_NON_BLOCKING flags.
  */
 static int
 JNIThread_WriteV21( JNIEnv *env, audio_output_t *p_aout, block_t *p_buffer )
@@ -823,8 +840,17 @@ JNIThread_Play( JNIEnv *env, audio_output_t *p_aout,
 p_buffer-i_nb_samples -= i_samples;
 if( p_buffer-i_buffer == 0 )
 *pp_buffer = NULL;
-}
 
+/* HACK: There is a known issue in audiotrack, due to an internal
+ * timeout within the AudioTrackThread. It happens after android
+ * 4.4.2, it's not a problem for Android 5.0 since we use an other way
+ * to write samples. A working hack is to wait a little between each
+ * write. This hack is done only for API 19 (AudioTimestamp was added
+ * in API 19). */
+
+if( jfields.AudioTimestamp.clazz  !jfields.AudioTrack.writeV21 )
+*p_wait = FRAMES_TO_US( i_samples ) / 2;
+}
 return i_ret = 0 ? VLC_SUCCESS : VLC_EGENERIC;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: fix play wait delay

2015-03-05 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Mar  5 19:03:31 
2015 +0100| [ad5b2e3ca73b343c9def5325928197318498b1e4] | committer: 
Jean-Baptiste Kempf

audiotrack: fix play wait delay

Don't postpone delay when a command is received.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad5b2e3ca73b343c9def5325928197318498b1e4
---

 modules/audio_output/audiotrack.c |   31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 8b19dfe..42b2d35 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -893,7 +893,7 @@ JNIThread( void *data )
 bool b_error = false;
 bool b_paused = false;
 block_t *p_buffer = NULL;
-mtime_t i_play_wait = 0;
+mtime_t i_play_deadline = 0;
 JNIEnv* env;
 
 jni_attach_thread( env, THREAD_NAME );
@@ -921,18 +921,19 @@ JNIThread( void *data )
 continue;
 }
 
-if( p_cmd-id == CMD_PLAY  p_buffer == p_cmd-in.play.p_buffer
- i_play_wait  0 )
+if( p_cmd-id == CMD_PLAY  i_play_deadline  0 )
 {
-int i_ret = 0;
-mtime_t i_deadline = mdate() + i_play_wait;
-
-while( p_cmd == TAILQ_FIRST( p_sys-thread_cmd_queue )
-i_ret != ETIMEDOUT  p_sys-b_thread_run )
-i_ret = vlc_cond_timedwait( p_sys-cond, p_sys-mutex,
-i_deadline );
-i_play_wait = 0;
-continue;
+if( mdate()  i_play_deadline )
+i_play_deadline = 0;
+else
+{
+int i_ret = 0;
+while( p_cmd == TAILQ_FIRST( p_sys-thread_cmd_queue )
+i_ret != ETIMEDOUT  p_sys-b_thread_run )
+i_ret = vlc_cond_timedwait( p_sys-cond, p_sys-mutex,
+i_play_deadline );
+continue;
+}
 }
 
 /* process a command */
@@ -960,6 +961,9 @@ JNIThread( void *data )
 p_buffer = NULL;
 break;
 case CMD_PLAY:
+{
+mtime_t i_play_wait = 0;
+
 assert( p_sys-p_audiotrack );
 if( b_error )
 break;
@@ -969,7 +973,10 @@ JNIThread( void *data )
   i_play_wait ) != VLC_SUCCESS;
 if( p_buffer != NULL )
 b_remove_cmd = false;
+if( i_play_wait  0 )
+i_play_deadline = mdate() + i_play_wait;
 break;
+}
 case CMD_PAUSE:
 assert( p_sys-p_audiotrack );
 if( b_error )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: move variable in good scope

2015-03-05 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Mar  5 19:03:30 
2015 +0100| [c65d83da3936d86cd8baae478b0688975946d93a] | committer: 
Jean-Baptiste Kempf

audiotrack: move variable in good scope

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c65d83da3936d86cd8baae478b0688975946d93a
---

 modules/audio_output/audiotrack.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 7ac723a..8b19dfe 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -475,12 +475,12 @@ JNIThread_TimeGet( JNIEnv *env, audio_output_t *p_aout, 
mtime_t *p_delay )
 aout_sys_t *p_sys = p_aout-sys;
 jlong i_frame_pos;
 uint32_t i_audiotrack_delay = 0;
-mtime_t i_current_time = mdate();
 
 if( p_sys-i_samples_queued == 0 )
 return -1;
 if( p_sys-p_audioTimestamp )
 {
+mtime_t i_current_time = mdate();
 /* Android doc:
  * getTimestamp: Poll for a timestamp on demand.
  *

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: wait more when internal buffer is full

2015-03-05 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Mar  5 19:03:32 
2015 +0100| [8770588670798b80daa16be57f830fed69d40791] | committer: 
Jean-Baptiste Kempf

audiotrack: wait more when internal buffer is full

Less CPU usage.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8770588670798b80daa16be57f830fed69d40791
---

 modules/audio_output/audiotrack.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 42b2d35..a8eb020 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -808,8 +808,11 @@ JNIThread_Play( JNIEnv *env, audio_output_t *p_aout,
 msg_Err( p_aout, Write failed: %s, str );
 }
 } else if( i_ret == 0 )
-*p_wait = FRAMES_TO_US( p_buffer-i_nb_samples );
-else
+{
+/* audiotrack internal buffer is full, wait a little: between 10ms and
+ * 20ms depending on devices or rate */
+*p_wait = FRAMES_TO_US( p_sys-i_max_audiotrack_samples / 20 );
+} else
 {
 uint32_t i_samples = i_ret / p_sys-i_bytes_per_frame;
 p_sys-i_samples_queued -= i_samples;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: deactivate getTimestamp

2015-03-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Mar  3 18:05:40 
2015 +0100| [a9b19e4ac55d8493e17650ce50ecefa5808950a7] | committer: 
Jean-Baptiste Kempf

audiotrack: deactivate getTimestamp

It is maybe miss used, but the delay reported by this function is not coherent.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a9b19e4ac55d8493e17650ce50ecefa5808950a7
---

 modules/audio_output/audiotrack.c |4 
 1 file changed, 4 insertions(+)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index ce7f6db..e21e31e 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -81,6 +81,8 @@ struct aout_sys_t {
 #include audio_output/volume.h
 
 //#define AUDIOTRACK_USE_FLOAT
+// TODO: activate getTimestamp for new android versions
+//#define AUDIOTRACK_USE_TIMESTAMP
 
 vlc_module_begin ()
 set_shortname( AudioTrack )
@@ -263,8 +265,10 @@ InitJNIFields( audio_output_t *p_aout )
 } else
 GET_ID( GetMethodID, AudioTrack.write, write, ([BII)I, true );
 
+#ifdef AUDIOTRACK_USE_TIMESTAMP
 GET_ID( GetMethodID, AudioTrack.getTimestamp,
 getTimestamp, (Landroid/media/AudioTimestamp;)Z, false );
+#endif
 GET_ID( GetMethodID, AudioTrack.getPlaybackHeadPosition,
 getPlaybackHeadPosition, ()I, true );
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: add WriteV21 (for Lollipop)

2015-03-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Mar  3 18:05:39 
2015 +0100| [4ea3c30718e2dca1652415c70dc956560c48] | committer: 
Jean-Baptiste Kempf

audiotrack: add WriteV21 (for Lollipop)

There is a new write method that can be non blocking and that can use a direct
ByteBuffer (no memcpy between java and jni).

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4ea3c30718e2dca1652415c70dc956560c48
---

 modules/audio_output/audiotrack.c |   71 +++--
 1 file changed, 68 insertions(+), 3 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 104abc6..ce7f6db 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -55,8 +55,9 @@ struct aout_sys_t {
 /* Owned by JNIThread */
 jobject p_audiotrack; /* AudioTrack ref */
 jobject p_audioTimestamp; /* AudioTimestamp ref */
-jbyteArray p_bytearray; /* ByteArray ref */
+jbyteArray p_bytearray; /* ByteArray ref (for Write) */
 size_t i_bytearray_size; /* size of the ByteArray */
+jobject p_bytebuffer; /* ByteBuffer ref (for WriteV21) */
 audio_sample_format_t fmt; /* fmt setup by Start */
 uint32_t i_pos_initial; /* initial position set by getPlaybackHeadPosition 
*/
 uint32_t i_samples_written; /* number of samples written since last flush 
*/
@@ -150,6 +151,7 @@ static struct
 jmethodID flush;
 jmethodID pause;
 jmethodID write;
+jmethodID writeV21;
 jmethodID getPlaybackHeadPosition;
 jmethodID getTimestamp;
 jmethodID getMinBufferSize;
@@ -158,6 +160,7 @@ static struct
 jint ERROR;
 jint ERROR_BAD_VALUE;
 jint ERROR_INVALID_OPERATION;
+jint WRITE_NON_BLOCKING;
 } AudioTrack;
 struct {
 jint ENCODING_PCM_8BIT;
@@ -251,7 +254,14 @@ InitJNIFields( audio_output_t *p_aout )
 GET_ID( GetMethodID, AudioTrack.stop, stop, ()V, true );
 GET_ID( GetMethodID, AudioTrack.flush, flush, ()V, true );
 GET_ID( GetMethodID, AudioTrack.pause, pause, ()V, true );
-GET_ID( GetMethodID, AudioTrack.write, write, ([BII)I, true );
+
+GET_ID( GetMethodID, AudioTrack.writeV21, write, 
(Ljava/nio/ByteBuffer;II)I, false );
+if( jfields.AudioTrack.writeV21 )
+{
+jfields.AudioTrack.write = NULL;
+GET_CONST_INT( AudioTrack.WRITE_NON_BLOCKING, WRITE_NON_BLOCKING, 
true );
+} else
+GET_ID( GetMethodID, AudioTrack.write, write, ([BII)I, true );
 
 GET_ID( GetMethodID, AudioTrack.getTimestamp,
 getTimestamp, (Landroid/media/AudioTimestamp;)Z, false );
@@ -717,6 +727,50 @@ JNIThread_Write( JNIEnv *env, audio_output_t *p_aout, 
block_t *p_buffer )
 return JNI_AT_CALL_INT( write, p_sys-p_bytearray, 0, i_data );
 }
 
+/**
+ * JNIThread_Write doesn't always work on Lollipop. Probably because audiotrack
+ * buffer size is bigger than the one we pass in ctor arguments (and there is
+ * no way to know it). It's not an issue since there is a new write method that
+ * is non blocking.
+ */
+static int
+JNIThread_WriteV21( JNIEnv *env, audio_output_t *p_aout, block_t *p_buffer )
+{
+aout_sys_t *p_sys = p_aout-sys;
+int i_ret;
+
+if( !p_sys-p_bytebuffer )
+{
+jobject p_bytebuffer;
+
+p_bytebuffer = (*env)-NewDirectByteBuffer( env, p_buffer-p_buffer,
+p_buffer-i_buffer );
+if( !p_bytebuffer )
+return jfields.AudioTrack.ERROR_BAD_VALUE;
+
+p_sys-p_bytebuffer = (*env)-NewGlobalRef( env, p_bytebuffer );
+(*env)-DeleteLocalRef( env, p_bytebuffer );
+
+if( !p_sys-p_bytebuffer || (*env)-ExceptionOccurred( env ) )
+{
+p_sys-p_bytebuffer = NULL;
+(*env)-ExceptionClear( env );
+return jfields.AudioTrack.ERROR_BAD_VALUE;
+}
+}
+
+i_ret = JNI_AT_CALL_INT( writeV21, p_sys-p_bytebuffer, p_buffer-i_buffer,
+ jfields.AudioTrack.WRITE_NON_BLOCKING );
+if( i_ret  0 )
+{
+/* don't delete the bytebuffer if we wrote nothing, keep it for next
+ * call */
+(*env)-DeleteGlobalRef( env, p_sys-p_bytebuffer );
+p_sys-p_bytebuffer = NULL;
+}
+return i_ret;
+}
+
 static int
 JNIThread_Play( JNIEnv *env, audio_output_t *p_aout,
 block_t **pp_buffer, mtime_t *p_wait )
@@ -725,7 +779,10 @@ JNIThread_Play( JNIEnv *env, audio_output_t *p_aout,
 block_t *p_buffer = *pp_buffer;
 int i_ret;
 
-i_ret = JNIThread_Write( env, p_aout, p_buffer );
+if( jfields.AudioTrack.writeV21 )
+i_ret = JNIThread_WriteV21( env, p_aout, p_buffer );
+else
+i_ret = JNIThread_Write( env, p_aout, p_buffer );
 
 if( i_ret  0 ) {
 if( jfields.AudioManager.has_ERROR_DEAD_OBJECT
@@ -816,6 +873,12 @@ JNIThread_Flush( JNIEnv *env

[vlc-commits] audiotrack: fix audioTimestamp leak

2015-02-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Feb 20 16:52:00 
2015 +0100| [b74397521d4aa02c6036f9474bd00a879019ae91] | committer: 
Jean-Baptiste Kempf

audiotrack: fix audioTimestamp leak

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b74397521d4aa02c6036f9474bd00a879019ae91
---

 modules/audio_output/audiotrack.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 9b2abeb..10a65fa 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -607,6 +607,12 @@ JNIThread_Stop( JNIEnv *env, bool *p_error, audio_output_t 
*p_aout )
 JNI_AT_CALL_VOID( release );
 (*env)-DeleteGlobalRef( env, p_sys-p_audiotrack );
 p_sys-p_audiotrack = NULL;
+
+if( p_sys-p_audioTimestamp )
+{
+(*env)-DeleteGlobalRef( env, p_sys-p_audioTimestamp );
+p_sys-p_audioTimestamp = NULL;
+}
 }
 
 static void

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] libvlc_MetaRequest: increment item i_preparse_depth

2015-03-26 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Mar 25 14:46:25 
2015 +| [f9aab1fe3415553299d5956f520571ce195939b0] | committer: 
Jean-Baptiste Kempf

libvlc_MetaRequest: increment item i_preparse_depth

libvlc_MetaRequest comes from the user, so we can increment i_preparse_depth to
force a preparsing.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f9aab1fe3415553299d5956f520571ce195939b0
---

 src/libvlc.c |4 
 1 file changed, 4 insertions(+)

diff --git a/src/libvlc.c b/src/libvlc.c
index cff3784..34824da 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -608,6 +608,10 @@ int libvlc_MetaRequest(libvlc_int_t *libvlc, input_item_t 
*item,
 if (unlikely(priv-parser == NULL))
 return VLC_ENOMEM;
 
+vlc_mutex_lock( item-lock );
+if( item-i_preparse_depth == 0 )
+item-i_preparse_depth = 1;
+vlc_mutex_unlock( item-lock );
 playlist_preparser_Push(priv-parser, item, i_options);
 return VLC_SUCCESS;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: remove debug log

2015-03-26 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Mar 25 15:39:54 
2015 +| [23c8d864bb82c2b464c1c2b03b483afd9d11802b] | committer: 
Jean-Baptiste Kempf

mediacodec: remove debug log

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=23c8d864bb82c2b464c1c2b03b483afd9d11802b
---

 modules/codec/omxil/android_mediacodec.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 1bb05a4..798bec4 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1085,7 +1085,6 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 }
 }
 i_output_ret = GetOutput(p_dec, env, p_pic, timeout);
-msg_Err(p_dec, i_output_ret: %d, i_output_ret);
 if (i_output_ret == -1) {
 p_sys-error_state = true;
 break;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] libvlc: add libvlc_media_get_codec_description

2015-01-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Jan 12 09:39:14 
2015 +| [7458af47e6db6134a8cd96098cbe542a5511e95c] | committer: 
Jean-Baptiste Kempf

libvlc: add libvlc_media_get_codec_description

Get codec description from media elementary stream.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7458af47e6db6134a8cd96098cbe542a5511e95c
---

 include/vlc/libvlc_media.h |   15 +++
 lib/libvlc.sym |1 +
 lib/media.c|   20 
 3 files changed, 36 insertions(+)

diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index c93d87b..d3fb9f5 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -589,6 +589,21 @@ LIBVLC_API
 unsigned libvlc_media_tracks_get( libvlc_media_t *p_md,
   libvlc_media_track_t ***tracks );
 
+/**
+ * Get codec description from media elementary stream
+ *
+ * \version LibVLC 3.0.0 and later.
+ *
+ * \see libvlc_media_track_t
+ *
+ * \param i_type i_type from libvlc_media_track_t
+ * \param i_codec i_codec or i_original_fourcc from libvlc_media_track_t
+ *
+ * \return codec description
+ */
+LIBVLC_API
+const char *libvlc_media_get_codec_description( libvlc_track_type_t i_type,
+uint32_t i_codec );
 
 /**
  * Release media descriptor's elementary streams description array
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index f0512c6..494097e 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -83,6 +83,7 @@ libvlc_media_discoverer_start
 libvlc_media_discoverer_stop
 libvlc_media_duplicate
 libvlc_media_event_manager
+libvlc_media_get_codec_description
 libvlc_media_get_duration
 libvlc_media_get_meta
 libvlc_media_get_mrl
diff --git a/lib/media.c b/lib/media.c
index 7d4bbb9..7e455f7 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -868,6 +868,26 @@ libvlc_media_tracks_get( libvlc_media_t *p_md, 
libvlc_media_track_t *** pp_es )
 return i_es;
 }
 
+/**
+ * Get codec description from media elementary stream
+ **/
+const char *
+libvlc_media_get_codec_description( libvlc_track_type_t i_type,
+uint32_t i_codec )
+{
+switch( i_type )
+{
+case libvlc_track_audio:
+return vlc_fourcc_GetDescription( AUDIO_ES, i_codec );
+case libvlc_track_video:
+return vlc_fourcc_GetDescription( VIDEO_ES, i_codec );
+case libvlc_track_text:
+return vlc_fourcc_GetDescription( SPU_ES, i_codec );
+case libvlc_track_unknown:
+default:
+return vlc_fourcc_GetDescription( UNKNOWN_ES, i_codec );
+}
+}
 
 /**
  * Release media descriptor's elementary streams description array

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] preparser: pass meta request options to Preparse

2015-01-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jan  8 16:10:01 
2015 +| [f65838e2a37cb453dc55f5490dad32f6353a118a] | committer: 
Jean-Baptiste Kempf

preparser: pass meta request options to Preparse

Network files will only be preparsed if META_REQUEST_OPTION_SCOPE_NETWORK
option is set (option not set by default by vlc playlist).

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f65838e2a37cb453dc55f5490dad32f6353a118a
---

 src/playlist/preparser.c |   51 ++
 1 file changed, 42 insertions(+), 9 deletions(-)

diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
index b44b9f8..96171e3 100644
--- a/src/playlist/preparser.c
+++ b/src/playlist/preparser.c
@@ -34,6 +34,14 @@
 /*
  * Structures/definitions
  */
+typedef struct preparser_entry_t preparser_entry_t;
+
+struct preparser_entry_t
+{
+input_item_t*p_item;
+input_item_meta_request_option_t i_options;
+};
+
 struct playlist_preparser_t
 {
 vlc_object_t*object;
@@ -42,7 +50,7 @@ struct playlist_preparser_t
 vlc_mutex_t lock;
 vlc_cond_t  wait;
 boolb_live;
-input_item_t  **pp_waiting;
+preparser_entry_t  **pp_waiting;
 int i_waiting;
 };
 
@@ -74,12 +82,17 @@ playlist_preparser_t *playlist_preparser_New( vlc_object_t 
*parent )
 void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t 
*p_item,
   input_item_meta_request_option_t i_options )
 {
-vlc_gc_incref( p_item );
-VLC_UNUSED( i_options );
+preparser_entry_t *p_entry = malloc( sizeof(preparser_entry_t) );
+
+if ( !p_entry )
+return;
+p_entry-p_item = p_item;
+p_entry-i_options = i_options;
+vlc_gc_incref( p_entry-p_item );
 
 vlc_mutex_lock( p_preparser-lock );
 INSERT_ELEM( p_preparser-pp_waiting, p_preparser-i_waiting,
- p_preparser-i_waiting, p_item );
+ p_preparser-i_waiting, p_entry );
 if( !p_preparser-b_live )
 {
 if( vlc_clone_detach( NULL, Thread, p_preparser,
@@ -104,7 +117,9 @@ void playlist_preparser_Delete( playlist_preparser_t 
*p_preparser )
 /* Remove pending item to speed up preparser thread exit */
 while( p_preparser-i_waiting  0 )
 {
-vlc_gc_decref( p_preparser-pp_waiting[0] );
+preparser_entry_t *p_entry = p_preparser-pp_waiting[0];
+vlc_gc_decref( p_entry-p_item );
+free( p_entry );
 REMOVE_ELEM( p_preparser-pp_waiting, p_preparser-i_waiting, 0 );
 }
 
@@ -127,13 +142,27 @@ void playlist_preparser_Delete( playlist_preparser_t 
*p_preparser )
 /**
  * This function preparses an item when needed.
  */
-static void Preparse( vlc_object_t *obj, input_item_t *p_item )
+static void Preparse( vlc_object_t *obj, input_item_t *p_item,
+  input_item_meta_request_option_t i_options )
 {
 vlc_mutex_lock( p_item-lock );
 int i_type = p_item-i_type;
 vlc_mutex_unlock( p_item-lock );
 
-if( i_type != ITEM_TYPE_FILE )
+bool b_preparse = false;
+switch (i_type) {
+case ITEM_TYPE_FILE:
+case ITEM_TYPE_DIRECTORY:
+case ITEM_TYPE_PLAYLIST:
+case ITEM_TYPE_NODE:
+b_preparse = true;
+break;
+case ITEM_TYPE_NET:
+if (i_options  META_REQUEST_OPTION_SCOPE_NETWORK)
+b_preparse = true;
+break;
+}
+if( !b_preparse )
 {
 input_item_SetPreparsed( p_item, true );
 return;
@@ -201,12 +230,16 @@ static void *Thread( void *data )
 for( ;; )
 {
 input_item_t *p_current;
+input_item_meta_request_option_t i_options;
 
 /* */
 vlc_mutex_lock( p_preparser-lock );
 if( p_preparser-i_waiting  0 )
 {
-p_current = p_preparser-pp_waiting[0];
+preparser_entry_t *p_entry = p_preparser-pp_waiting[0];
+p_current = p_entry-p_item;
+i_options = p_entry-i_options;
+free( p_entry );
 REMOVE_ELEM( p_preparser-pp_waiting, p_preparser-i_waiting, 0 );
 }
 else
@@ -220,7 +253,7 @@ static void *Thread( void *data )
 if( !p_current )
 break;
 
-Preparse( obj, p_current );
+Preparse( obj, p_current, i_options );
 
 Art( p_preparser, p_current );
 vlc_gc_decref(p_current);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] input: preparsing not only for files

2015-01-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jan  8 16:10:02 
2015 +| [84bc465af520c6b3128a540dce58d56aa23f0940] | committer: 
Jean-Baptiste Kempf

input: preparsing not only for files

It's safe since preparser won't be called for network files if
META_REQUEST_OPTION_SCOPE_NETWORK option is not set.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=84bc465af520c6b3128a540dce58d56aa23f0940
---

 src/input/input.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index aa5a835..48e085d 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2225,11 +2225,8 @@ static int InputSourceInit( input_thread_t *p_input,
 }
 else
 {
-/* Preparsing is only for file:// */
 if( *psz_demux )
 goto error;
-if( strcmp( psz_access, file ) )
-goto error;
 msg_Dbg( p_input, trying to pre-parse %s,  psz_path );
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] lib: change libvlc_media_discoverer_t creation

2015-01-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jan  8 16:10:00 
2015 +| [fa7924acb3613ab69c5221517391134623f68fd9] | committer: 
Jean-Baptiste Kempf

lib: change libvlc_media_discoverer_t creation

libvlc_media_discoverer_new_from_name was creating a services_discovery_t and
was starting it, so libvlc_MediaDiscovererStarted event (or any other events)
could not be received.

To fix that, Split libvlc_media_discoverer_new_from_name into
libvlc_media_discoverer_new and libvlc_media_discoverer_start. That way, we can
attach events between create and start.

libvlc_media_discoverer_new_from_name is now deprecated, but it still works
like before.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fa7924acb3613ab69c5221517391134623f68fd9
---

 NEWS  |6 
 include/vlc/libvlc_media_discoverer.h |   52 ++--
 lib/libvlc.sym|3 ++
 lib/media_discoverer.c|   53 ++---
 4 files changed, 100 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index d2b7aa8..c468ada 100644
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,12 @@ Qt interface:
 Skins2:
  * Support key accelerators
 
+libVLC:
+ * split of libvlc_media_discoverer_new_from_name into 
libvlc_media_discoverer_new,
+   libvlc_media_discoverer_new and libvlc_media_discoverer_start.
+   This allows to attach media events between create and start.
+
+
 
 Changes between 2.1.x and 2.2.0:
 
diff --git a/include/vlc/libvlc_media_discoverer.h 
b/include/vlc/libvlc_media_discoverer.h
index cf263b0..2626802 100644
--- a/include/vlc/libvlc_media_discoverer.h
+++ b/include/vlc/libvlc_media_discoverer.h
@@ -48,15 +48,61 @@ extern C {
 typedef struct libvlc_media_discoverer_t libvlc_media_discoverer_t;
 
 /**
- * Discover media service by name.
+ * \deprecated Use libvlc_media_discoverer_new() and 
libvlc_media_discoverer_start().
+ */
+LIBVLC_DEPRECATED LIBVLC_API libvlc_media_discoverer_t *
+libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
+   const char * psz_name );
+
+/**
+ * Create a media discoverer object by name.
+ *
+ * After this object is created, you should attach to events in order to be
+ * notified of the discoverer state.
+ * You should also attach to media_list events in order to be notified of new
+ * items discovered.
+ *
+ * You need to call libvlc_media_discoverer_start() in order to start the
+ * discovery.
+ *
+ * \see libvlc_media_discoverer_media_list
+ * \see libvlc_media_discoverer_event_manager
+ * \see libvlc_media_discoverer_start
  *
  * \param p_inst libvlc instance
  * \param psz_name service name
  * \return media discover object or NULL in case of error
+ * \version LibVLC 3.0.0 or later
  */
 LIBVLC_API libvlc_media_discoverer_t *
-libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
-   const char * psz_name );
+libvlc_media_discoverer_new( libvlc_instance_t * p_inst,
+ const char * psz_name );
+
+/**
+ * Start media discovery.
+ *
+ * To stop it, call libvlc_media_discoverer_stop() or
+ * libvlc_media_discoverer_release() directly.
+ *
+ * \see libvlc_media_discoverer_stop
+ *
+ * \param p_mdis media discover object
+ * \return -1 in case of error, 0 otherwise
+ * \version LibVLC 3.0.0 or later
+ */
+LIBVLC_API int
+libvlc_media_discoverer_start( libvlc_media_discoverer_t * p_mdis );
+
+/**
+ * Stop media discovery.
+ *
+ * \see libvlc_media_discoverer_start
+ *
+ * \param p_mdis media discover object
+ * \version LibVLC 3.0.0 or later
+ */
+LIBVLC_API void
+libvlc_media_discoverer_stop( libvlc_media_discoverer_t * p_mdis );
 
 /**
  * Release media discover object. If the reference count reaches 0, then
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index c0c66dd..f0512c6 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -76,8 +76,11 @@ libvlc_media_discoverer_event_manager
 libvlc_media_discoverer_is_running
 libvlc_media_discoverer_localized_name
 libvlc_media_discoverer_media_list
+libvlc_media_discoverer_new
 libvlc_media_discoverer_new_from_name
 libvlc_media_discoverer_release
+libvlc_media_discoverer_start
+libvlc_media_discoverer_stop
 libvlc_media_duplicate
 libvlc_media_event_manager
 libvlc_media_get_duration
diff --git a/lib/media_discoverer.c b/lib/media_discoverer.c
index b126c95..a2532cb 100644
--- a/lib/media_discoverer.c
+++ b/lib/media_discoverer.c
@@ -181,12 +181,9 @@ static void services_discovery_ended( const vlc_event_t * 
p_event,
 
 /**
  *   new (Public)
- *
- * Init an object.
  **/
 libvlc_media_discoverer_t *
-libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst

[vlc-commits] android: simplify/improve the attachment of a thread to the Java VM

2015-04-03 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 12:43:39 
2015 +0200| [16c0f37bc7f2a76fa34a9922c8d2152206c79a14] | committer: 
Jean-Baptiste Kempf

android: simplify/improve the attachment of a thread to the Java VM

There is now only one way to get a JNIEnv: jni_get_env. This function use the
thread-specific data (TSD) areas to save a JNIEnv into a TSD key. The thread
will be automatically detached to the Java VM when it's canceled or exited.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=16c0f37bc7f2a76fa34a9922c8d2152206c79a14
---

 modules/audio_output/audiotrack.c |   23 ++
 modules/codec/omxil/android_mediacodec.c  |   26 +++--
 modules/codec/omxil/omxil.c   |8 +++-
 modules/video_output/android/android_window.c |7 ++-
 modules/video_output/android/nativewindow.c   |7 +++
 modules/video_output/android/surface.c|3 ---
 6 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 1471793..813fd6b 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -149,10 +149,7 @@ struct thread_cmd
 };
 
 #define THREAD_NAME android_audiotrack
-
-extern int jni_attach_thread(JNIEnv **env, const char *thread_name);
-extern void jni_detach_thread();
-extern int jni_get_env(JNIEnv **env);
+extern JNIEnv *jni_get_env(const char *name);
 
 static struct
 {
@@ -220,7 +217,7 @@ InitJNIFields( audio_output_t *p_aout )
 {
 static vlc_mutex_t lock = VLC_STATIC_MUTEX;
 static int i_init_state = -1;
-bool ret, b_attached = false;
+bool ret;
 jclass clazz;
 jfieldID field;
 JNIEnv* env = NULL;
@@ -230,15 +227,10 @@ InitJNIFields( audio_output_t *p_aout )
 if( i_init_state != -1 )
 goto end;
 
-if( jni_get_env(env)  0 )
+if (!(env = jni_get_env(THREAD_NAME)))
 {
-jni_attach_thread( env, THREAD_NAME );
-if( !env )
-{
-i_init_state = 0;
-goto end;
-}
-b_attached = true;
+i_init_state = 0;
+goto end;
 }
 
 #define CHECK_EXCEPTION( what, critical ) do { \
@@ -378,8 +370,6 @@ end:
 ret = i_init_state == 1;
 if( !ret )
 msg_Err( p_aout, AudioTrack jni init failed );
-if( b_attached )
-jni_detach_thread();
 vlc_mutex_unlock( lock );
 return ret;
 }
@@ -1264,7 +1254,7 @@ JNIThread( void *data )
 mtime_t i_play_deadline = 0;
 JNIEnv* env;
 
-jni_attach_thread( env, THREAD_NAME );
+env = jni_get_env(THREAD_NAME);
 
 vlc_mutex_lock( p_sys-mutex );
 if( !env )
@@ -1420,7 +1410,6 @@ end:
 (*env)-DeleteGlobalRef( env, p_sys-p_floatarray );
 if( p_sys-p_bytebuffer )
 (*env)-DeleteGlobalRef( env, p_sys-p_bytebuffer );
-jni_detach_thread();
 }
 vlc_mutex_unlock( p_sys-mutex );
 return NULL;
diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index be2e196..d9058d3 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -49,9 +49,8 @@
 #define INFO_TRY_AGAIN_LATER-1
 
 #define THREAD_NAME android_mediacodec
+extern JNIEnv *jni_get_env(const char *name);
 
-extern int jni_attach_thread(JNIEnv **env, const char *thread_name);
-extern void jni_detach_thread();
 /* JNI functions to get/set an Android Surface object. */
 extern jobject jni_LockAndGetAndroidJavaSurface();
 extern void jni_UnlockAndroidSurface();
@@ -372,7 +371,8 @@ static int OpenDecoder(vlc_object_t *p_this)
 p_dec-b_need_packetized = true;
 
 JNIEnv* env = NULL;
-jni_attach_thread(env, THREAD_NAME);
+if (!(env = jni_get_env(THREAD_NAME)))
+goto error;
 
 for (int i = 0; classes[i].name; i++) {
 *(jclass*)((uint8_t*)p_sys + classes[i].offset) =
@@ -651,8 +651,6 @@ loopclean:
 p_sys-buffer_info = (*env)-NewGlobalRef(env, p_sys-buffer_info);
 (*env)-DeleteLocalRef(env, format);
 
-jni_detach_thread();
-
 const int timestamp_fifo_size = 32;
 p_sys-timestamp_fifo = timestamp_FifoNew(timestamp_fifo_size);
 if (!p_sys-timestamp_fifo)
@@ -661,7 +659,6 @@ loopclean:
 return VLC_SUCCESS;
 
  error:
-jni_detach_thread();
 CloseDecoder(p_this);
 return VLC_EGENERIC;
 }
@@ -679,7 +676,10 @@ static void CloseDecoder(vlc_object_t *p_this)
  * to prevent the vout from using destroyed output buffers. */
 if (p_sys-direct_rendering)
 InvalidateAllPictures(p_dec);
-jni_attach_thread(env, THREAD_NAME);
+
+if (!(env = jni_get_env(THREAD_NAME)))
+goto cleanup;
+
 if (p_sys-input_buffers)
 (*env)-DeleteGlobalRef(env, p_sys-input_buffers);
 if (p_sys-output_buffers)
@@ -701,8 +701,8 @@ static void CloseDecoder(vlc_object_t *p_this

[vlc-commits] audiotrack: clip buffer size between 250ms and 1000ms

2015-04-03 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 12:43:41 
2015 +0200| [31ff9f18446d57f7a6139418f63f179d11249aca] | committer: 
Jean-Baptiste Kempf

audiotrack: clip buffer size between 250ms and 1000ms

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=31ff9f18446d57f7a6139418f63f179d11249aca
---

 modules/audio_output/audiotrack.c |   26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index f3d3268..06842bd 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -34,6 +34,9 @@
 #include vlc_plugin.h
 #include vlc_aout.h
 
+#define MIN_AUDIOTRACK_BUFFER_US INT64_C(25)  // 250ms
+#define MAX_AUDIOTRACK_BUFFER_US INT64_C(100) // 1000ms
+
 static int  Open( vlc_object_t * );
 static void Close( vlc_object_t * );
 static void Stop( audio_output_t * );
@@ -528,6 +531,7 @@ AudioTrack_New( JNIEnv *env, audio_output_t *p_aout,
 unsigned int i_rate,
 vlc_fourcc_t i_vlc_format,
 uint16_t i_physical_channels,
+int i_bytes_per_frame,
 int *p_audiotrack_size )
 {
 int i_size, i_min_buffer_size, i_channel_config, i_format;
@@ -582,7 +586,19 @@ AudioTrack_New( JNIEnv *env, audio_output_t *p_aout,
 if( i_vlc_format == VLC_CODEC_SPDIFB )
 i_size = ( i_min_buffer_size / AOUT_SPDIF_SIZE + 1 ) * AOUT_SPDIF_SIZE;
 else
+{
+/* Optimal buffer size: i_min_buffer_size * 4 but between 250ms and
+ * 1000ms */
+mtime_t i_time, i_clipped_time;
+
 i_size = i_min_buffer_size * 4;
+i_time = (i_size / i_bytes_per_frame) * CLOCK_FREQ / i_rate;
+
+i_clipped_time = VLC_CLIP( i_time, MIN_AUDIOTRACK_BUFFER_US,
+ MAX_AUDIOTRACK_BUFFER_US );
+if( i_clipped_time != i_time )
+i_size = i_rate * i_clipped_time * i_bytes_per_frame / CLOCK_FREQ;
+}
 
 /* create AudioTrack object */
 p_audiotrack = JNI_AT_NEW( jfields.AudioManager.STREAM_MUSIC, i_rate,
@@ -612,7 +628,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 aout_sys_t *p_sys = p_aout-sys;
 JNIEnv *env;
 jobject p_audiotrack = NULL;
-int i_nb_channels, i_audiotrack_size;
+int i_nb_channels, i_audiotrack_size, i_bytes_per_frame;
 
 if( !( env = jni_get_env( THREAD_NAME ) ) )
 return VLC_EGENERIC;
@@ -672,6 +688,9 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 
 do
 {
+i_bytes_per_frame = i_nb_channels *
+aout_BitsPerSample( p_sys-fmt.i_format ) / 8;
+
 /* Try to create an AudioTrack with the most advanced channel and
  * format configuration. If AudioTrack_New fails, try again with a less
  * advanced format (PCM S16N). If it fails again, try again with Stereo
@@ -679,6 +698,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 p_audiotrack = AudioTrack_New( env, p_aout, p_sys-fmt.i_rate,
p_sys-fmt.i_format,
p_sys-fmt.i_physical_channels,
+   i_bytes_per_frame,
i_audiotrack_size );
 if( !p_audiotrack )
 {
@@ -734,9 +754,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 aout_CheckChannelReorder( NULL, p_chans_out,
   p_sys-fmt.i_physical_channels,
   p_sys-p_chan_table );
-p_sys-i_bytes_per_frame = i_nb_channels *
-   aout_BitsPerSample( p_sys-fmt.i_format ) /
-   8;
+p_sys-i_bytes_per_frame = i_bytes_per_frame;
 }
 p_sys-i_max_audiotrack_samples = BYTES_TO_FRAMES( i_audiotrack_size );
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: initialize jni fields during first open

2015-04-03 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 12:43:42 
2015 +0200| [1048c3a1ea5d54847f9d7b1d1d400f69ab56507c] | committer: 
Jean-Baptiste Kempf

mediacodec: initialize jni fields during first open

No need to re-init all jni fields each time we open MediaCodec decoder.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1048c3a1ea5d54847f9d7b1d1d400f69ab56507c
---

 modules/codec/omxil/android_mediacodec.c |  261 +-
 1 file changed, 147 insertions(+), 114 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=1048c3a1ea5d54847f9d7b1d1d400f69ab56507c
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec/omxil: blacklist samsung VP8 decoder

2015-04-03 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 12:43:43 
2015 +0200| [06e37373c2ff6daaa069f04c94cbef880c6aad6f] | committer: 
Jean-Baptiste Kempf

mediacodec/omxil: blacklist samsung VP8 decoder

Fixes #14227

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=06e37373c2ff6daaa069f04c94cbef880c6aad6f
---

 modules/codec/omxil/android_mediacodec.c |2 ++
 modules/codec/omxil/omxil.c  |3 +++
 2 files changed, 5 insertions(+)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index cacfe1e..aa90cc4 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -397,6 +397,8 @@ static bool codec_is_blacklisted( const char *p_name, 
unsigned int i_name_len )
 OMX.google.,
 /* crashes mediaserver */
 OMX.MTK.VIDEO.DECODER.MPEG4,
+/* Not working or crashing (Samsung) */
+OMX.SEC.vp8.dec,
 NULL,
  };
 
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 9211f76..16eb50e 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1141,6 +1141,9 @@ static int OpenGeneric( vlc_object_t *p_this, bool 
b_encode )
  * it until we can make it work properly. */
 if (!strcmp(p_sys-ppsz_components[i], OMX.Nvidia.vc1.decode))
 continue;
+/* This codec doesn't work or crashes */
+if (!strcmp(p_sys-ppsz_components[i], OMX.SEC.vp8.dec))
+continue;
 #endif
 omx_error = InitialiseComponent(p_dec, p_sys-ppsz_components[i],
 p_sys-omx_handle);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: get rid of the thread and the queue

2015-04-03 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 12:43:40 
2015 +0200| [29a4acbd4de4718f17ee015b45c3bf013b1fd339] | committer: 
Jean-Baptiste Kempf

audiotrack: get rid of the thread and the queue

No need to have a queue inside VLC since we can control the size of the
AudioTrack buffer. There is now only one delay to handle, the AudioTrack one.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=29a4acbd4de4718f17ee015b45c3bf013b1fd339
---

 modules/audio_output/audiotrack.c |  690 +++--
 1 file changed, 134 insertions(+), 556 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=29a4acbd4de4718f17ee015b45c3bf013b1fd339
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: don't wait indefinitely for data

2015-04-03 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Mar 31 07:22:48 
2015 +| [008a2122acf9d8d544c1540298970a1169e2ac41] | committer: 
Jean-Baptiste Kempf

mediacodec: don't wait indefinitely for data

The decoder can be in a bad state without throwing any exception.

Issue seen with a MPEG4 sample on a Tegra 3 and Tegra K1 tablet but may happens
on others devices/samples.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=008a2122acf9d8d544c1540298970a1169e2ac41
---

 modules/codec/omxil/android_mediacodec.c |   19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index aa90cc4..adf88e2 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1087,6 +1087,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 p_dec-fmt_out.video.i_sar_den = p_dec-fmt_in.video.i_sar_den;
 }
 
+unsigned int i_attempts = 0;
 jlong timeout = 0;
 int i_output_ret = 0;
 int i_input_ret = 0;
@@ -1123,12 +1124,22 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 if (i_output_ret == -1) {
 p_sys-error_state = true;
 break;
-} else if (i_output_ret == 0  p_pic) {
-picture_Release(p_pic);
-p_pic = NULL;
+} else if (i_output_ret == 0) {
+if (p_pic) {
+picture_Release(p_pic);
+p_pic = NULL;
+} else if (++i_attempts  100) {
+/* No p_pic, so no pixel_format, thereforce mediacodec
+ * didn't produce any output or events yet. Don't wait
+ * indefinitely and abort after 2seconds (100 * 2 * 10ms)
+ * without any data. Indeed, MediaCodec can fail without
+ * throwing any exception or error returns... */
+p_sys-error_state = true;
+break;
+}
 }
 }
-timeout = 10 * 1000;
+timeout = 10 * 1000; // 10 ms
 }
 
 endclean:

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: use input sample rate when using spdif

2015-04-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 20 10:15:29 
2015 +0200| [6006bd36562ad4565f5978f45c6e23b3792a4728] | committer: Thomas 
Guillem

audiotrack: use input sample rate when using spdif

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6006bd36562ad4565f5978f45c6e23b3792a4728
---

 modules/audio_output/audiotrack.c |   17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 450a90c..0347aee 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -847,12 +847,19 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 
 p_sys-fmt.i_original_channels = p_sys-fmt.i_physical_channels;
 
-i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
-jfields.AudioManager.STREAM_MUSIC 
);
-if( i_native_rate = 0 )
+if( b_spdif )
 {
-msg_Warn( p_aout, negative native rate ? Should not happen ! );
-i_native_rate = VLC_CLIP( p_sys-fmt.i_rate, 4000, 48000 );
+i_native_rate = p_sys-fmt.i_rate;
+}
+else
+{
+i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
+
jfields.AudioManager.STREAM_MUSIC );
+if( i_native_rate = 0 )
+{
+msg_Warn( p_aout, negative native rate ? Should not happen ! );
+i_native_rate = VLC_CLIP( p_sys-fmt.i_rate, 4000, 48000 );
+}
 }
 
 /* We can only accept U8, S16N, FL32, and AC3 */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: allow to open with a custom extra buffer

2015-04-24 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 19:06:13 
2015 +0200| [0621dfe359aaeb0f0cb26558712f264cc52a1e6d] | committer: Thomas 
Guillem

mediacodec: allow to open with a custom extra buffer

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0621dfe359aaeb0f0cb26558712f264cc52a1e6d
---

 modules/codec/omxil/android_mediacodec.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 873fb10..1e716af 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -143,6 +143,7 @@ struct decoder_sys_t
 char *name;
 
 void *p_extra_buffer;
+size_t i_extra_buffer;
 
 bool allocated;
 bool started;
@@ -529,10 +530,9 @@ loopclean:
  jfields.create_video_format, 
(*env)-NewStringUTF(env, mime),
  p_dec-fmt_in.video.i_width, 
p_dec-fmt_in.video.i_height);
 
-if (p_dec-fmt_in.i_extra) {
+if (p_dec-fmt_in.i_extra  !p_sys-p_extra_buffer) {
 uint32_t size = p_dec-fmt_in.i_extra;
 int buf_size = p_dec-fmt_in.i_extra + 20;
-jobject jextra_buffer;
 
 /* Don't free p_extra_buffer until Format use it, so until MediaCodec
  * is closed */
@@ -554,9 +554,15 @@ loopclean:
 } else {
 memcpy(p_sys-p_extra_buffer, p_dec-fmt_in.p_extra, size);
 }
+p_sys-i_extra_buffer = size;
+}
+if (p_sys-p_extra_buffer)
+{
+jobject jextra_buffer;
+
 jextra_buffer = (*env)-NewDirectByteBuffer( env,
  p_sys-p_extra_buffer,
- size);
+ p_sys-i_extra_buffer);
 if (CHECK_EXCEPTION() || !jextra_buffer)
 {
 msg_Warn(p_dec, java extra buffer allocation failed);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: factor DecodeVideo

2015-04-24 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr 24 10:05:31 
2015 +0200| [2ab78c748d6bc3e1c4412b780b3e7f11e786049e] | committer: Thomas 
Guillem

mediacodec: factor DecodeVideo

More comments, try to make it clearer, release p_block and p_pic in only one
place. It also fixes a p_block leak if we were not able to create a p_pic.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2ab78c748d6bc3e1c4412b780b3e7f11e786049e
---

 modules/codec/omxil/android_mediacodec.c |   80 ++
 1 file changed, 38 insertions(+), 42 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 1e716af..cf155dc 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1114,6 +1114,10 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 picture_t *p_pic = NULL;
 JNIEnv *env = NULL;
 block_t *p_block = pp_block ? *pp_block : NULL;
+unsigned int i_attempts = 0;
+jlong timeout = 0;
+int i_output_ret = 0;
+int i_input_ret = 0;
 bool b_error = false;
 
 if (p_sys-error_state)
@@ -1126,8 +1130,6 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 }
 
 if (p_block  p_block-i_flags  
(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) {
-block_Release(p_block);
-*pp_block = NULL;
 p_sys-i_preroll_end = 0;
 timestamp_FifoEmpty(p_sys-timestamp_fifo);
 if (p_sys-decoded) {
@@ -1177,23 +1179,12 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 p_dec-fmt_out.video.i_sar_den = p_dec-fmt_in.video.i_sar_den;
 }
 
-unsigned int i_attempts = 0;
-jlong timeout = 0;
-int i_output_ret = 0;
-int i_input_ret = 0;
 do {
-if (p_block  i_input_ret == 0) {
+if (p_block  i_input_ret == 0)
 i_input_ret = PutInput(p_dec, env, p_block, timeout);
-if (i_input_ret == 1) {
-block_Release(p_block);
-*pp_block = NULL;
-} else if (i_input_ret == -1) {
-b_error = true;
-break;
-}
-}
 
-if (i_output_ret == 0) {
+if (i_output_ret == 0)
+{
 /* FIXME: A new picture shouldn't be created each time.
  * If decoder_NewPicture fails because the decoder is
  * flushing/exiting, GetOutput will either fail (or crash in
@@ -1202,7 +1193,8 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
  * input is waiting for the output or vice-versa.  Therefore, call
  * decoder_NewPicture before GetOutput as a safeguard. */
 
-if (p_sys-pixel_format) {
+if (p_sys-pixel_format)
+{
 p_pic = decoder_NewPicture(p_dec);
 if (!p_pic) {
 msg_Warn(p_dec, NewPicture failed);
@@ -1210,14 +1202,16 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 }
 }
 i_output_ret = GetOutput(p_dec, env, p_pic, timeout);
-if (i_output_ret == -1) {
-b_error = true;
-break;
-} else if (i_output_ret == 0) {
-if (p_pic) {
+if (p_pic)
+{
+if (i_output_ret != 1) {
 picture_Release(p_pic);
 p_pic = NULL;
-} else if (++i_attempts  100) {
+}
+} else
+{
+if (i_output_ret == 0  i_input_ret == 0  ++i_attempts  
100)
+{
 /* No p_pic, so no pixel_format, thereforce mediacodec
  * didn't produce any output or events yet. Don't wait
  * indefinitely and abort after 2seconds (100 * 2 * 10ms)
@@ -1229,28 +1223,30 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 }
 }
 timeout = 10 * 1000; // 10 ms
-/* loop until input is processed or when we got an output pic */
-} while (p_block  i_input_ret != 1  i_output_ret != 1);
+/* loop until either the input or the output are processed (i_input_ret
+ * or i_output_ret == 1 ) or caused an error (i_input_ret or
+ * i_output_ret == -1 )*/
+} while (p_block  i_input_ret == 0  i_output_ret == 0);
+
+if (i_input_ret == -1 || i_output_ret == -1)
+b_error = true;
 
 endclean:
-if (p_sys-error_state || b_error || !p_sys-codec)
-{
-if( p_block )
-{
-block_Release(p_block);
-*pp_block = NULL;
-}
-if (p_pic)
-{
-picture_Release(p_pic);
-p_pic = NULL;
-}
 
-if (b_error  !p_sys-error_state) {
-/* Signal the error to the Java. */
-jni_EventHardwareAccelerationError

[vlc-commits] mediacodec: abort if there is no valid video size

2015-04-24 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 14:42:50 
2015 +0200| [2a09b420ae6126a8e6b7b457b1e9382ed6afa3d3] | committer: Thomas 
Guillem

mediacodec: abort if there is no valid video size

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2a09b420ae6126a8e6b7b457b1e9382ed6afa3d3
---

 modules/codec/omxil/android_mediacodec.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 5474acf..873fb10 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -732,10 +732,12 @@ static int OpenDecoder(vlc_object_t *p_this)
 case VLC_CODEC_VC1:
 case VLC_CODEC_VP8:
 case VLC_CODEC_VP9:
-break;
+if (p_dec-fmt_in.video.i_width  p_dec-fmt_in.video.i_height)
+break;
 default:
-msg_Dbg(p_dec, codec %4.4s not supported,
-(char *)p_dec-fmt_in.i_codec);
+msg_Dbg(p_dec, codec %4.4s or resolution (%dx%d) not supported,
+(char *)p_dec-fmt_in.i_codec,
+p_dec-fmt_in.video.i_width, p_dec-fmt_in.video.i_height);
 return VLC_EGENERIC;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: seperate MediaCodec Open/Close from Decoder Open/Close

2015-04-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 15:36:21 
2015 +0200| [08f6114d37faef0d4d2ae7dcde69112e6017d657] | committer: Thomas 
Guillem

mediacodec: seperate MediaCodec Open/Close from Decoder Open/Close

It's now safe to close and open MediaCodec during playback.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=08f6114d37faef0d4d2ae7dcde69112e6017d657
---

 modules/codec/omxil/android_mediacodec.c |  150 +-
 1 file changed, 104 insertions(+), 46 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index af6cb6e..6adbd89 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -29,6 +29,7 @@
 
 #include jni.h
 #include stdint.h
+#include assert.h
 
 #include vlc_common.h
 #include vlc_plugin.h
@@ -260,6 +261,7 @@ static const struct member members[] = {
  */
 static int  OpenDecoder(vlc_object_t *);
 static void CloseDecoder(vlc_object_t *);
+static void CloseMediaCodec(decoder_t *p_dec, JNIEnv *env);
 
 static picture_t *DecodeVideo(decoder_t *, block_t **);
 
@@ -386,17 +388,14 @@ end:
 }
 
 /*
- * OpenDecoder: Create the decoder instance
+ * OpenMediaCodec: Create the mediacodec instance
  */
-static int OpenDecoder(vlc_object_t *p_this)
+static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
 {
-decoder_t *p_dec = (decoder_t*)p_this;
-decoder_sys_t *p_sys;
-
-if (p_dec-fmt_in.i_cat != VIDEO_ES  !p_dec-b_force)
-return VLC_EGENERIC;
-
+decoder_sys_t *p_sys = p_dec-p_sys;
 const char *mime = NULL;
+size_t fmt_profile = 0;
+
 switch (p_dec-fmt_in.i_codec) {
 case VLC_CODEC_HEVC: mime = video/hevc; break;
 case VLC_CODEC_H264: mime = video/avc; break;
@@ -407,32 +406,12 @@ static int OpenDecoder(vlc_object_t *p_this)
 case VLC_CODEC_VP8:  mime = video/x-vnd.on2.vp8; break;
 case VLC_CODEC_VP9:  mime = video/x-vnd.on2.vp9; break;
 default:
-msg_Dbg(p_dec, codec %4.4s not supported, (char 
*)p_dec-fmt_in.i_codec);
-return VLC_EGENERIC;
+vlc_assert_unreachable();
 }
 
-size_t fmt_profile = 0;
 if (p_dec-fmt_in.i_codec == VLC_CODEC_H264)
 h264_get_profile_level(p_dec-fmt_in, fmt_profile, NULL, NULL);
 
-/* Allocate the memory needed to store the decoder's structure */
-if ((p_dec-p_sys = p_sys = calloc(1, sizeof(*p_sys))) == NULL)
-return VLC_ENOMEM;
-
-p_dec-pf_decode_video = DecodeVideo;
-
-p_dec-fmt_out.i_cat = p_dec-fmt_in.i_cat;
-p_dec-fmt_out.video = p_dec-fmt_in.video;
-p_dec-fmt_out.audio = p_dec-fmt_in.audio;
-p_dec-b_need_packetized = true;
-
-JNIEnv* env = NULL;
-if (!(env = jni_get_env(THREAD_NAME)))
-goto error;
-
-if (!InitJNIFields(p_dec, env))
-goto error;
-
 int num_codecs = (*env)-CallStaticIntMethod(env, 
jfields.media_codec_list_class,
  jfields.get_codec_count);
 jobject codec_name = NULL;
@@ -674,58 +653,137 @@ loopclean:
 p_sys-buffer_info = (*env)-NewGlobalRef(env, p_sys-buffer_info);
 (*env)-DeleteLocalRef(env, format);
 
-const int timestamp_fifo_size = 32;
-p_sys-timestamp_fifo = timestamp_FifoNew(timestamp_fifo_size);
-if (!p_sys-timestamp_fifo)
-goto error;
-
 return VLC_SUCCESS;
 
  error:
-CloseDecoder(p_this);
+CloseMediaCodec(p_dec, env);
 return VLC_EGENERIC;
 }
 
-static void CloseDecoder(vlc_object_t *p_this)
+/*
+ * CloseMediaCodec: Close the mediacodec instance
+ */
+static void CloseMediaCodec(decoder_t *p_dec, JNIEnv *env)
 {
-decoder_t *p_dec = (decoder_t *)p_this;
 decoder_sys_t *p_sys = p_dec-p_sys;
-JNIEnv *env = NULL;
 
 if (!p_sys)
 return;
 
+free(p_sys-name);
+p_sys-name = NULL;
+
 /* Invalidate all pictures that are currently in flight in order
  * to prevent the vout from using destroyed output buffers. */
-if (p_sys-direct_rendering)
+if (p_sys-direct_rendering) {
 InvalidateAllPictures(p_dec);
+p_sys-direct_rendering = false;
+}
 
-if (!(env = jni_get_env(THREAD_NAME)))
-goto cleanup;
-
-if (p_sys-input_buffers)
+if (p_sys-input_buffers) {
 (*env)-DeleteGlobalRef(env, p_sys-input_buffers);
-if (p_sys-output_buffers)
+p_sys-input_buffers = NULL;
+}
+if (p_sys-output_buffers) {
 (*env)-DeleteGlobalRef(env, p_sys-output_buffers);
+p_sys-output_buffers = NULL;
+}
 if (p_sys-codec) {
 if (p_sys-started

[vlc-commits] mediacodec: rework error handling in DecodeVideo

2015-04-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 14:48:55 
2015 +0200| [49e5fb3b5fa0274e03cb8bde27e479f8b5e095a1] | committer: Thomas 
Guillem

mediacodec: rework error handling in DecodeVideo

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=49e5fb3b5fa0274e03cb8bde27e479f8b5e095a1
---

 modules/codec/omxil/android_mediacodec.c |   24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index a1d289f..af6cb6e 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -147,7 +147,6 @@ struct decoder_sys_t
 bool started;
 bool decoded;
 bool error_state;
-bool error_event_sent;
 
 ArchitectureSpecificCopyData architecture_specific_data;
 
@@ -1038,12 +1037,16 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 picture_t *p_pic = NULL;
 JNIEnv *env = NULL;
 block_t *p_block = pp_block ? *pp_block : NULL;
+bool b_error = false;
 
 if (p_sys-error_state)
 goto endclean;
 
 if (!(env = jni_get_env(THREAD_NAME)))
+{
+b_error = true;
 goto endclean;
+}
 
 if (p_block  p_block-i_flags  
(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) {
 block_Release(p_block);
@@ -1060,7 +1063,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 (*env)-CallVoidMethod(env, p_sys-codec, jfields.flush);
 if (CHECK_EXCEPTION()) {
 msg_Warn(p_dec, Exception occurred in MediaCodec.flush);
-p_sys-error_state = true;
+b_error = true;
 }
 }
 p_sys-decoded = false;
@@ -1086,7 +1089,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 block_Release(p_block);
 *pp_block = NULL;
 } else if (i_input_ret == -1) {
-p_sys-error_state = true;
+b_error = true;
 break;
 }
 }
@@ -1109,7 +1112,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 }
 i_output_ret = GetOutput(p_dec, env, p_pic, timeout);
 if (i_output_ret == -1) {
-p_sys-error_state = true;
+b_error = true;
 break;
 } else if (i_output_ret == 0) {
 if (p_pic) {
@@ -1121,7 +1124,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
  * indefinitely and abort after 2seconds (100 * 2 * 10ms)
  * without any data. Indeed, MediaCodec can fail without
  * throwing any exception or error returns... */
-p_sys-error_state = true;
+b_error = true;
 break;
 }
 }
@@ -1131,20 +1134,23 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 } while (p_block  i_input_ret != 1  i_output_ret != 1);
 
 endclean:
-if (p_sys-error_state) {
+if (p_sys-error_state || b_error)
+{
 if( p_block )
 {
 block_Release(p_block);
 *pp_block = NULL;
 }
 if (p_pic)
+{
 picture_Release(p_pic);
-p_pic = NULL;
+p_pic = NULL;
+}
 
-if (!p_sys-error_event_sent) {
+if (b_error  !p_sys-error_state) {
 /* Signal the error to the Java. */
 jni_EventHardwareAccelerationError();
-p_sys-error_event_sent = true;
+p_sys-error_state = true;
 }
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: handle vc1 delayed opening if there is no extradata

2015-04-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 15:34:33 
2015 +0200| [3bbd8b0cfb63cf294f0b110ae2515fbf9c3292ea] | committer: Thomas 
Guillem

mediacodec: handle vc1 delayed opening if there is no extradata

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3bbd8b0cfb63cf294f0b110ae2515fbf9c3292ea
---

 modules/codec/omxil/android_mediacodec.c |   35 +-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 6adbd89..5474acf 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -760,6 +760,17 @@ static int OpenDecoder(vlc_object_t *p_this)
 if (!p_dec-p_sys-timestamp_fifo)
 goto error;
 
+switch (p_dec-fmt_in.i_codec)
+{
+case VLC_CODEC_VC1:
+if (!p_dec-fmt_in.i_extra)
+{
+msg_Warn(p_dec, waiting for extra data for codec %4.4s,
+ (const char *)p_dec-fmt_in.i_codec);
+return VLC_SUCCESS;
+}
+break;
+}
 return OpenMediaCodec(p_dec, env);
 
  error:
@@ -1128,6 +1139,28 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 goto endclean;
 }
 
+/* try delayed opening if there is a new extra data */
+if (!p_sys-codec)
+{
+bool b_delayed_open = false;
+
+switch (p_dec-fmt_in.i_codec)
+{
+case VLC_CODEC_VC1:
+if (p_dec-fmt_in.i_extra)
+b_delayed_open = true;
+default:
+break;
+}
+if (b_delayed_open  OpenMediaCodec(p_dec, env) != VLC_SUCCESS)
+{
+b_error = true;
+goto endclean;
+}
+}
+if (!p_sys-codec)
+goto endclean;
+
 /* Use the aspect ratio provided by the input (ie read from packetizer).
  * Don't check the current value of the aspect ratio in fmt_out, since we
  * want to allow changes in it to propagate. */
@@ -1192,7 +1225,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 } while (p_block  i_input_ret != 1  i_output_ret != 1);
 
 endclean:
-if (p_sys-error_state || b_error)
+if (p_sys-error_state || b_error || !p_sys-codec)
 {
 if( p_block )
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: use the JNI ByteBuffer allocation instead of the Java one

2015-04-23 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 14:32:44 
2015 +0200| [40cb8ff17f92a001870191626c8a012abf78fe53] | committer: Thomas 
Guillem

mediacodec: use the JNI ByteBuffer allocation instead of the Java one

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=40cb8ff17f92a001870191626c8a012abf78fe53
---

 modules/codec/omxil/android_mediacodec.c |   49 +++---
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 5d78953..a1d289f 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -141,6 +141,8 @@ struct decoder_sys_t
 int stride, slice_height;
 char *name;
 
+void *p_extra_buffer;
+
 bool allocated;
 bool started;
 bool decoded;
@@ -175,7 +177,6 @@ struct jfields
 jmethodID release_output_buffer;
 jmethodID create_video_format, set_integer, set_bytebuffer, get_integer;
 jmethodID buffer_info_ctor;
-jmethodID allocate_direct, limit;
 jfieldID size_field, offset_field, pts_field;
 };
 static struct jfields jfields;
@@ -250,10 +251,6 @@ static const struct member members[] = {
 { size, I, android/media/MediaCodec$BufferInfo, OFF(size_field), 
FIELD, true },
 { offset, I, android/media/MediaCodec$BufferInfo, OFF(offset_field), 
FIELD, true },
 { presentationTimeUs, J, android/media/MediaCodec$BufferInfo, 
OFF(pts_field), FIELD, true },
-
-{ allocateDirect, (I)Ljava/nio/ByteBuffer;, java/nio/ByteBuffer, 
OFF(allocate_direct), STATIC_METHOD, true },
-{ limit, (I)Ljava/nio/Buffer;, java/nio/ByteBuffer, OFF(limit), 
METHOD, true },
-
 { NULL, NULL, NULL, 0, 0, false },
 };
 
@@ -555,29 +552,44 @@ loopclean:
  p_dec-fmt_in.video.i_width, 
p_dec-fmt_in.video.i_height);
 
 if (p_dec-fmt_in.i_extra) {
-// Allocate a byte buffer via allocateDirect in java instead of 
NewDirectByteBuffer,
-// since the latter doesn't allocate storage of its own, and we don't 
know how long
-// the codec uses the buffer.
-int buf_size = p_dec-fmt_in.i_extra + 20;
-jobject bytebuf = (*env)-CallStaticObjectMethod(env, 
jfields.byte_buffer_class,
- 
jfields.allocate_direct, buf_size);
 uint32_t size = p_dec-fmt_in.i_extra;
-uint8_t *ptr = (*env)-GetDirectBufferAddress(env, bytebuf);
+int buf_size = p_dec-fmt_in.i_extra + 20;
+jobject jextra_buffer;
+
+/* Don't free p_extra_buffer until Format use it, so until MediaCodec
+ * is closed */
+p_sys-p_extra_buffer = malloc(buf_size);
+if (!p_sys-p_extra_buffer)
+{
+msg_Warn(p_dec, extra buffer allocation failed);
+goto error;
+}
 if (p_dec-fmt_in.i_codec == VLC_CODEC_H264  
((uint8_t*)p_dec-fmt_in.p_extra)[0] == 1) {
 convert_sps_pps(p_dec, p_dec-fmt_in.p_extra, 
p_dec-fmt_in.i_extra,
-ptr, buf_size,
+p_sys-p_extra_buffer, buf_size,
 size, p_sys-nal_size);
 } else if (p_dec-fmt_in.i_codec == VLC_CODEC_HEVC) {
 convert_hevc_nal_units(p_dec, p_dec-fmt_in.p_extra,
-   p_dec-fmt_in.i_extra, ptr, buf_size,
+   p_dec-fmt_in.i_extra,
+   p_sys-p_extra_buffer, buf_size,
size, p_sys-nal_size);
 } else {
-memcpy(ptr, p_dec-fmt_in.p_extra, size);
+memcpy(p_sys-p_extra_buffer, p_dec-fmt_in.p_extra, size);
+}
+jextra_buffer = (*env)-NewDirectByteBuffer( env,
+ p_sys-p_extra_buffer,
+ size);
+if (CHECK_EXCEPTION() || !jextra_buffer)
+{
+msg_Warn(p_dec, java extra buffer allocation failed);
+free(p_sys-p_extra_buffer);
+p_sys-p_extra_buffer = NULL;
+goto error;
 }
-(*env)-CallObjectMethod(env, bytebuf, jfields.limit, size);
 (*env)-CallVoidMethod(env, format, jfields.set_bytebuffer,
-   (*env)-NewStringUTF(env, csd-0), bytebuf);
-(*env)-DeleteLocalRef(env, bytebuf);
+   (*env)-NewStringUTF(env, csd-0),
+   jextra_buffer);
+(*env)-DeleteLocalRef(env, jextra_buffer);
 }
 
 p_sys-direct_rendering = var_InheritBool(p_dec, CFG_PREFIX dr);
@@ -715,6 +727,7 @@ static void CloseDecoder(vlc_object_t *p_this)
 (*env)-DeleteGlobalRef(env, p_sys-buffer_info);
 
 cleanup:
+free(p_sys-p_extra_buffer);
 free(p_sys-name);
 ArchitectureSpecificCopyHooksDestroy(p_sys-pixel_format, 
p_sys-architecture_specific_data

[vlc-commits] decoder: fix audio-desync with a value 3000ms

2015-04-22 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr 17 18:44:07 
2015 +0200| [af698180ba3d9f73630edd6dad4617ce1d012785] | committer: Thomas 
Guillem

decoder: fix audio-desync with a value  3000ms

Add the delay to ts_bound when calling input_clock_ConvertTS (For audio,
i_ts_bound is 3000ms).

Fixes #4847

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=af698180ba3d9f73630edd6dad4617ce1d012785
---

 src/input/decoder.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 79a83c1..38a5c69 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -670,6 +670,8 @@ static void DecoderFixTs( decoder_t *p_dec, mtime_t 
*pi_ts0, mtime_t *pi_ts1,
 *pi_ts0 += i_es_delay;
 if( pi_ts1  *pi_ts1  VLC_TS_INVALID )
 *pi_ts1 += i_es_delay;
+if( i_ts_bound != INT64_MAX )
+i_ts_bound += i_es_delay;
 if( input_clock_ConvertTS( VLC_OBJECT(p_dec), p_clock, i_rate, 
pi_ts0, pi_ts1, i_ts_bound ) ) {
 if( pi_ts1 != NULL )
 msg_Err(p_dec, Could not convert timestamps %PRId64

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec/omxil: blacklist MTK VC1 decoder

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr 28 14:50:50 
2015 +0200| [8a8b2b73f305ff66db912a4acc24831351bcb444] | committer: Thomas 
Guillem

mediacodec/omxil: blacklist MTK VC1 decoder

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8a8b2b73f305ff66db912a4acc24831351bcb444
---

 modules/codec/omxil/utils.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 31a491d..4ec6981 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -336,6 +336,8 @@ bool OMXCodec_IsBlacklisted( const char *p_name, unsigned 
int i_name_len )
 OMX.Nvidia.vc1.decode,
 /* crashes mediaserver */
 OMX.MTK.VIDEO.DECODER.MPEG4,
+/* black screen */
+OMX.MTK.VIDEO.DECODER.VC1,
 /* Not working or crashing (Samsung) */
 OMX.SEC.vp8.dec,
 NULL

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] packetizer: h264: expose nal type in h264_nal.h

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 17:20:50 
2015 +0200| [bafd580455afa7b234382bf0e29e0a4cfc73a972] | committer: Thomas 
Guillem

packetizer: h264: expose nal type in h264_nal.h

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bafd580455afa7b234382bf0e29e0a4cfc73a972
---

 modules/packetizer/h264.c |   23 ---
 modules/packetizer/h264_nal.h |   23 +++
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 6401ea4..ed8fad2 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -147,29 +147,6 @@ struct decoder_sys_t
 cc_data_t cc_next;
 };
 
-enum nal_unit_type_e
-{
-NAL_UNKNOWN = 0,
-NAL_SLICE   = 1,
-NAL_SLICE_DPA   = 2,
-NAL_SLICE_DPB   = 3,
-NAL_SLICE_DPC   = 4,
-NAL_SLICE_IDR   = 5,/* ref_idc != 0 */
-NAL_SEI = 6,/* ref_idc == 0 */
-NAL_SPS = 7,
-NAL_PPS = 8,
-NAL_AU_DELIMITER= 9
-/* ref_idc == 0 for 6,9,10,11,12 */
-};
-
-/* Defined in H.264 annex D */
-enum sei_type_e
-{
-SEI_PIC_TIMING = 1,
-SEI_USER_DATA_REGISTERED = 4,
-SEI_RECOVERY_POINT = 6
-};
-
 #define BLOCK_FLAG_PRIVATE_AUD (1  BLOCK_FLAG_PRIVATE_SHIFT)
 
 static block_t *Packetize( decoder_t *, block_t ** );
diff --git a/modules/packetizer/h264_nal.h b/modules/packetizer/h264_nal.h
index 7028fcf..6358fe6 100644
--- a/modules/packetizer/h264_nal.h
+++ b/modules/packetizer/h264_nal.h
@@ -43,6 +43,29 @@
 #define PROFILE_H264_MVC_STEREO_HIGH  128
 #define PROFILE_H264_MVC_MULTIVIEW_HIGH   118
 
+enum nal_unit_type_e
+{
+NAL_UNKNOWN = 0,
+NAL_SLICE   = 1,
+NAL_SLICE_DPA   = 2,
+NAL_SLICE_DPB   = 3,
+NAL_SLICE_DPC   = 4,
+NAL_SLICE_IDR   = 5,/* ref_idc != 0 */
+NAL_SEI = 6,/* ref_idc == 0 */
+NAL_SPS = 7,
+NAL_PPS = 8,
+NAL_AU_DELIMITER= 9
+/* ref_idc == 0 for 6,9,10,11,12 */
+};
+
+/* Defined in H.264 annex D */
+enum sei_type_e
+{
+SEI_PIC_TIMING = 1,
+SEI_USER_DATA_REGISTERED = 4,
+SEI_RECOVERY_POINT = 6
+};
+
 /* Parse the SPS/PPS Metadata and convert it to annex b format */
 int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
  uint32_t i_buf_size, uint8_t *p_out_buf,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: parse SPS/PPS, fix H264 via live streaming

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 09:28:39 
2015 +0200| [c3694bf84a4100f6d86daff68dc15e1362329000] | committer: Thomas 
Guillem

mediacodec: parse SPS/PPS, fix H264 via live streaming

Don't abort if H264 fmt doesn't have any valid size or extra. The SPS/PPS will
be parsed from DecodeVideo, MediaCodec will be (re)started if video size changes
and valid SPS/PPS will be sent via BUFFER_FLAG_CODEC_CONFIG flag.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c3694bf84a4100f6d86daff68dc15e1362329000
---

 modules/codec/omxil/android_mediacodec.c |  182 +-
 1 file changed, 176 insertions(+), 6 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 1b0c275..74b28e4 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -152,10 +152,14 @@ struct decoder_sys_t
 size_t i_config_buffer;
 bool b_config_resend;
 
+int i_width;
+int i_height;
+
 bool allocated;
 bool started;
 bool decoded;
 bool error_state;
+bool b_new_block;
 
 ArchitectureSpecificCopyData architecture_specific_data;
 
@@ -395,6 +399,32 @@ end:
 return ret;
 }
 
+static int H264GetSPSPPS(uint8_t *p_buf, size_t i_buf,
+ uint8_t **pp_sps_buf, size_t *p_sps_size,
+ uint8_t **pp_pps_buf, size_t *p_pps_size,
+ struct nal_sps *p_sps)
+{
+uint8_t *p_sps_buf, *p_pps_buf;
+size_t i_sps_size, i_pps_size;
+
+if (h264_get_spspps(p_buf, i_buf, p_sps_buf, i_sps_size,
+p_pps_buf, i_pps_size) == 0)
+{
+if (pp_sps_buf  p_sps_size )
+{
+*pp_sps_buf = p_sps_buf;
+*p_sps_size = i_sps_size;
+}
+if (pp_pps_buf  p_pps_size )
+{
+*pp_pps_buf = p_pps_buf;
+*p_pps_size = i_pps_size;
+}
+return h264_parse_sps(p_sps_buf, i_sps_size, p_sps);
+} else
+return -1;
+}
+
 /*
  * OpenMediaCodec: Create the mediacodec instance
  */
@@ -533,10 +563,6 @@ loopclean:
 p_sys-allocated = true;
 p_sys-codec = (*env)-NewGlobalRef(env, p_sys-codec);
 
-jobject format = (*env)-CallStaticObjectMethod(env, 
jfields.media_format_class,
- jfields.create_video_format, 
(*env)-NewStringUTF(env, mime),
- p_dec-fmt_in.video.i_width, 
p_dec-fmt_in.video.i_height);
-
 /* Either we use a csd-0 buffer that is provided before codec
  * initialisation via the MediaFormat class, or use a CODEC_CONFIG buffer
  * that can be provided during playback (and must be provided after a flush
@@ -566,7 +592,32 @@ loopclean:
 memcpy(p_sys-p_csd0_buffer, p_dec-fmt_in.p_extra, size);
 }
 p_sys-i_csd0_buffer = size;
+
+if (p_dec-fmt_in.i_codec == VLC_CODEC_H264)
+{
+struct nal_sps sps;
+
+if (H264GetSPSPPS(p_sys-p_csd0_buffer, p_sys-i_csd0_buffer,
+  NULL, NULL, NULL, NULL, sps) == 0)
+{
+msg_Warn(p_dec, SPS found, id: %d size: %dx%d (vs %dx%d),
+ sps.i_id, sps.i_width, sps.i_height,
+ p_sys-i_width, p_sys-i_height);
+p_sys-i_width = sps.i_width;
+p_sys-i_height = sps.i_height;
+}
+}
+}
+
+if (!p_sys-i_width  !p_sys-i_height)
+{
+msg_Err(p_dec, invalid size, abort MediaCodec);
+goto error;
 }
+jobject format = (*env)-CallStaticObjectMethod(env, 
jfields.media_format_class,
+ jfields.create_video_format, 
(*env)-NewStringUTF(env, mime),
+ p_sys-i_width, p_sys-i_height);
+
 if (p_sys-p_csd0_buffer)
 {
 jobject jcsd0_buffer;
@@ -742,6 +793,8 @@ static int OpenDecoder(vlc_object_t *p_this)
 
 switch (p_dec-fmt_in.i_codec) {
 case VLC_CODEC_H264:
+/* We can handle h264 without a valid video size */
+break;
 case VLC_CODEC_HEVC:
 case VLC_CODEC_H263:
 case VLC_CODEC_MP4V:
@@ -775,12 +828,24 @@ static int OpenDecoder(vlc_object_t *p_this)
 p_dec-fmt_out.audio = p_dec-fmt_in.audio;
 p_dec-b_need_packetized = true;
 
+p_dec-p_sys-i_width = p_dec-fmt_in.video.i_width;
+p_dec-p_sys-i_height = p_dec-fmt_in.video.i_height;
+
 p_dec-p_sys-timestamp_fifo = timestamp_FifoNew(32);
 if (!p_dec-p_sys-timestamp_fifo)
 goto error;
 
+p_dec-p_sys-b_new_block = true;
+
 switch (p_dec-fmt_in.i_codec)
 {
+case VLC_CODEC_H264:
+if (!p_dec-p_sys-i_width || !p_dec-p_sys-i_height)
+{
+msg_Warn(p_dec, waiting for sps/pps for codec %4.4s

[vlc-commits] mediacodec: factor GetMediaCodecName

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 11:53:22 
2015 +0200| [ccfcd3ff24befbe7b4180075b40d972f4a1d49c8] | committer: Thomas 
Guillem

mediacodec: factor GetMediaCodecName

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ccfcd3ff24befbe7b4180075b40d972f4a1d49c8
---

 modules/codec/omxil/android_mediacodec.c |   85 +-
 1 file changed, 49 insertions(+), 36 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index cac2df0..4824111 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -433,50 +433,23 @@ static int H264GetSPSPPS(uint8_t *p_buf, size_t i_buf,
 return -1;
 }
 
-/*
- * OpenMediaCodec: Create the mediacodec instance
- */
-static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
+static jstring GetMediaCodecName(decoder_t *p_dec, JNIEnv *env,
+ const char *mime, jstring jmime)
 {
 decoder_sys_t *p_sys = p_dec-p_sys;
-const char *mime = NULL;
+int num_codecs;
 size_t fmt_profile = 0;
-int i_ret = VLC_EGENERIC;
-jstring jmime = NULL;
 jstring jcodec_name = NULL;
-jobject jcodec = NULL;
-jobject jcsd0_buffer = NULL;
-jstring jcsd0_string = NULL;
-jobject jformat = NULL;
-jstring jrotation_string = NULL;
-jobject jinput_buffers = NULL;
-jobject joutput_buffers = NULL;
-jobject jbuffer_info = NULL;
-
-switch (p_dec-fmt_in.i_codec) {
-case VLC_CODEC_HEVC: mime = video/hevc; break;
-case VLC_CODEC_H264: mime = video/avc; break;
-case VLC_CODEC_H263: mime = video/3gpp; break;
-case VLC_CODEC_MP4V: mime = video/mp4v-es; break;
-case VLC_CODEC_WMV3: mime = video/x-ms-wmv; break;
-case VLC_CODEC_VC1:  mime = video/wvc1; break;
-case VLC_CODEC_VP8:  mime = video/x-vnd.on2.vp8; break;
-case VLC_CODEC_VP9:  mime = video/x-vnd.on2.vp9; break;
-default:
-vlc_assert_unreachable();
-}
-
-jmime = (*env)-NewStringUTF(env, mime);
-if (!jmime)
-return VLC_EGENERIC;
 
 if (p_dec-fmt_in.i_codec == VLC_CODEC_H264)
 h264_get_profile_level(p_dec-fmt_in, fmt_profile, NULL, NULL);
 
-int num_codecs = (*env)-CallStaticIntMethod(env, 
jfields.media_codec_list_class,
- jfields.get_codec_count);
+num_codecs = (*env)-CallStaticIntMethod(env,
+ jfields.media_codec_list_class,
+ jfields.get_codec_count);
 
-for (int i = 0; i  num_codecs; i++) {
+for (int i = 0; i  num_codecs; i++)
+{
 jobject codec_capabilities = NULL;
 jobject profile_levels = NULL;
 jobject info = NULL;
@@ -500,7 +473,8 @@ static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
 if ((*env)-CallBooleanMethod(env, info, jfields.is_encoder))
 goto loopclean;
 
-codec_capabilities = (*env)-CallObjectMethod(env, info, 
jfields.get_capabilities_for_type,
+codec_capabilities = (*env)-CallObjectMethod(env, info,
+  
jfields.get_capabilities_for_type,
   jmime);
 if (CHECK_EXCEPTION()) {
 msg_Warn(p_dec, Exception occurred in 
MediaCodecInfo.getCapabilitiesForType);
@@ -571,7 +545,46 @@ loopclean:
 if (found)
 break;
 }
+return jcodec_name;
+}
+
+/*
+ * OpenMediaCodec: Create the mediacodec instance
+ */
+static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
+{
+decoder_sys_t *p_sys = p_dec-p_sys;
+const char *mime = NULL;
+int i_ret = VLC_EGENERIC;
+jstring jmime = NULL;
+jstring jcodec_name = NULL;
+jobject jcodec = NULL;
+jobject jcsd0_buffer = NULL;
+jstring jcsd0_string = NULL;
+jobject jformat = NULL;
+jstring jrotation_string = NULL;
+jobject jinput_buffers = NULL;
+jobject joutput_buffers = NULL;
+jobject jbuffer_info = NULL;
+
+switch (p_dec-fmt_in.i_codec) {
+case VLC_CODEC_HEVC: mime = video/hevc; break;
+case VLC_CODEC_H264: mime = video/avc; break;
+case VLC_CODEC_H263: mime = video/3gpp; break;
+case VLC_CODEC_MP4V: mime = video/mp4v-es; break;
+case VLC_CODEC_WMV3: mime = video/x-ms-wmv; break;
+case VLC_CODEC_VC1:  mime = video/wvc1; break;
+case VLC_CODEC_VP8:  mime = video/x-vnd.on2.vp8; break;
+case VLC_CODEC_VP9:  mime = video/x-vnd.on2.vp9; break;
+default:
+vlc_assert_unreachable();
+}
+
+jmime = (*env)-NewStringUTF(env, mime

[vlc-commits] mediacodec: allow interlaced picture only after API 21

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 13:34:56 
2015 +0200| [61949af475e7ec5b1198cc4376d0b7ebcf166056] | committer: Thomas 
Guillem

mediacodec: allow interlaced picture only after API 21

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=61949af475e7ec5b1198cc4376d0b7ebcf166056
---

 modules/codec/omxil/android_mediacodec.c |8 
 1 file changed, 8 insertions(+)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 4824111..4e924fe 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1396,6 +1396,14 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 if (p_sys-error_state)
 goto endclean;
 
+/* Allow interlaced picture only after API 21 */
+if (p_block  p_block-i_flags  BLOCK_FLAG_INTERLACED_MASK
+ !(jfields.get_input_buffer  jfields.get_output_buffer))
+{
+b_error = true;
+goto endclean;
+}
+
 if (!(env = jni_get_env(THREAD_NAME)))
 {
 b_error = true;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: add decoder_UpdateVideoFormat call

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 14:05:58 
2015 +0200| [2ce0d5826c032505615189ab257201ad52be9f67] | committer: Thomas 
Guillem

mediacodec: add decoder_UpdateVideoFormat call

A failing decoder_UpdateVideoFormat is critical, unlike a failing
decoder_NewPicture.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2ce0d5826c032505615189ab257201ad52be9f67
---

 modules/codec/omxil/android_mediacodec.c |   21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 4e924fe..03e98fc 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -152,6 +152,7 @@ struct decoder_sys_t
 size_t i_config_buffer;
 bool b_config_resend;
 
+bool b_update_format;
 int i_width;
 int i_height;
 
@@ -763,6 +764,7 @@ static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
 jbuffer_info = (*env)-NewObject(env, jfields.buffer_info_class,
  jfields.buffer_info_ctor);
 p_sys-buffer_info = (*env)-NewGlobalRef(env, jbuffer_info);
+p_sys-b_update_format = true;
 
 i_ret = VLC_SUCCESS;
 
@@ -1280,6 +1282,7 @@ static int GetOutput(decoder_t *p_dec, JNIEnv *env, 
picture_t *p_pic, jlong time
 p_sys-slice_height = 0;
 p_sys-stride = p_dec-fmt_out.video.i_width;
 }
+p_sys-b_update_format = true;
 }
 return 0;
 }
@@ -1466,9 +1469,13 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 /* Use the aspect ratio provided by the input (ie read from packetizer).
  * Don't check the current value of the aspect ratio in fmt_out, since we
  * want to allow changes in it to propagate. */
-if (p_dec-fmt_in.video.i_sar_num != 0  p_dec-fmt_in.video.i_sar_den != 
0) {
+if (p_dec-fmt_in.video.i_sar_num != 0  p_dec-fmt_in.video.i_sar_den != 0
+  (p_dec-fmt_out.video.i_sar_num != p_dec-fmt_in.video.i_sar_num ||
+ p_dec-fmt_out.video.i_sar_den != p_dec-fmt_in.video.i_sar_den))
+{
 p_dec-fmt_out.video.i_sar_num = p_dec-fmt_in.video.i_sar_num;
 p_dec-fmt_out.video.i_sar_den = p_dec-fmt_in.video.i_sar_den;
+p_sys-b_update_format = true;
 }
 
 do {
@@ -1487,10 +1494,20 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 
 if (p_sys-pixel_format)
 {
+if (p_sys-b_update_format)
+{
+p_sys-b_update_format = false;
+if (decoder_UpdateVideoFormat(p_dec) != 0)
+{
+msg_Err(p_dec, decoder_UpdateVideoFormat failed);
+b_error = true;
+break;
+}
+}
 p_pic = decoder_NewPicture(p_dec);
 if (!p_pic) {
 msg_Warn(p_dec, NewPicture failed);
-goto endclean;
+break;
 }
 }
 i_output_ret = GetOutput(p_dec, env, p_pic, timeout);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] h264_nal: add h264_get_spspps

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 18:22:51 
2015 +0200| [f815b9e52a34d27271b0cae71a25c277be6f4a0b] | committer: Thomas 
Guillem

h264_nal: add h264_get_spspps

It fetches the SPS and PPS pointers from an Annex B buffer.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f815b9e52a34d27271b0cae71a25c277be6f4a0b
---

 modules/packetizer/h264_nal.c |   68 +
 modules/packetizer/h264_nal.h |6 
 2 files changed, 74 insertions(+)

diff --git a/modules/packetizer/h264_nal.c b/modules/packetizer/h264_nal.c
index 2a375c2..9e7eb70 100644
--- a/modules/packetizer/h264_nal.c
+++ b/modules/packetizer/h264_nal.c
@@ -22,6 +22,8 @@
 
 #include limits.h
 
+static const uint8_t annexb_startcode[] = { 0x00, 0x00, 0x00, 0x01 };
+
 int convert_sps_pps( decoder_t *p_dec, const uint8_t *p_buf,
  uint32_t i_buf_size, uint8_t *p_out_buf,
  uint32_t i_out_buf_size, uint32_t *p_sps_pps_size,
@@ -138,6 +140,72 @@ void convert_h264_to_annexb( uint8_t *p_buf, uint32_t 
i_len,
 }
 }
 
+int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
+ uint8_t **pp_sps, size_t *p_sps_size,
+ uint8_t **pp_pps, size_t *p_pps_size )
+{
+uint8_t *p_sps = NULL, *p_pps = NULL;
+size_t i_sps_size = 0, i_pps_size = 0;
+int i_nal_type = NAL_UNKNOWN;
+
+while( true )
+{
+int i_inc = 0;
+
+if( i_buf  5  memcmp( p_buf, annexb_startcode, 4 ) == 0 )
+{
+i_nal_type = p_buf[4]  0x1F;
+
+/* size of startcode + nal_type */
+i_inc = 5;
+
+/* pointer to the beginning of the sps/pps  */
+if( i_nal_type == NAL_SPS  !p_sps )
+p_sps = p_buf;
+if( i_nal_type == NAL_PPS  !p_pps )
+p_pps = p_buf;
+} else {
+i_inc = 1;
+}
+
+/* cf. 7.4.1.2.3 */
+if( i_nal_type == NAL_UNKNOWN || i_nal_type  18
+ || (i_nal_type = 10  i_nal_type = 12))
+return -1;
+
+/* update SPS/PPS size if the new NAL is different than the last one */
+if( !i_sps_size  p_sps  i_nal_type != NAL_SPS )
+i_sps_size = p_buf - p_sps;
+if( !i_pps_size  p_pps  i_nal_type != NAL_PPS )
+i_pps_size = p_buf - p_pps;
+
+/* SPS/PPS are before the slices */
+if (i_nal_type = NAL_SLICE  i_nal_type = NAL_SLICE_IDR )
+break;
+
+i_buf -= i_inc;
+p_buf += i_inc;
+
+if( i_buf == 0 )
+{
+/* update SPS/PPS size if we reach the end of the buffer */
+if( !i_sps_size  p_sps )
+i_sps_size = p_buf - p_sps;
+if( !i_pps_size  p_pps )
+i_pps_size = p_buf - p_pps;
+break;
+}
+}
+if( ( !p_sps || !i_sps_size )  ( !p_pps || !i_pps_size ) )
+return -1;
+*pp_sps = p_sps;
+*p_sps_size = i_sps_size;
+*pp_pps = p_pps;
+*p_pps_size = i_pps_size;
+
+return 0;
+}
+
 bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
 size_t *p_level, size_t *p_nal_size)
 {
diff --git a/modules/packetizer/h264_nal.h b/modules/packetizer/h264_nal.h
index 6358fe6..bc346cf 100644
--- a/modules/packetizer/h264_nal.h
+++ b/modules/packetizer/h264_nal.h
@@ -82,6 +82,12 @@ void convert_h264_to_annexb( uint8_t *p_buf, uint32_t i_len,
  size_t i_nal_size,
  struct H264ConvertState *state );
 
+/* Get the SPS/PPS pointers from an Annex B buffer
+ * Returns 0 if a SPS and/or a PPS is found */
+int h264_get_spspps( uint8_t *p_buf, size_t i_buf,
+ uint8_t **pp_sps, size_t *p_sps_size,
+ uint8_t **pp_pps, size_t *p_pps_size );
+
 /* Get level and Profile */
 bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
 size_t *p_level, size_t *p_nal_size);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: renome p_extra_buffer to p_csd0_buffer

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 09:13:53 
2015 +0200| [d149b6c011e5263051acf1e9582c95d02c29824d] | committer: Thomas 
Guillem

mediacodec: renome p_extra_buffer to p_csd0_buffer

Since it's the buffer containing the csd-0 configuration buffer.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d149b6c011e5263051acf1e9582c95d02c29824d
---

 modules/codec/omxil/android_mediacodec.c |   42 +++---
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index f98934d..45fe7981 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -142,8 +142,8 @@ struct decoder_sys_t
 int stride, slice_height;
 char *name;
 
-void *p_extra_buffer;
-size_t i_extra_buffer;
+void *p_csd0_buffer;
+size_t i_csd0_buffer;
 
 bool allocated;
 bool started;
@@ -530,50 +530,50 @@ loopclean:
  jfields.create_video_format, 
(*env)-NewStringUTF(env, mime),
  p_dec-fmt_in.video.i_width, 
p_dec-fmt_in.video.i_height);
 
-if (p_dec-fmt_in.i_extra  !p_sys-p_extra_buffer) {
+if (p_dec-fmt_in.i_extra  !p_sys-p_csd0_buffer) {
 uint32_t size = p_dec-fmt_in.i_extra;
 int buf_size = p_dec-fmt_in.i_extra + 20;
 
-/* Don't free p_extra_buffer until Format use it, so until MediaCodec
+/* Don't free p_csd0_buffer until Format use it, so until MediaCodec
  * is closed */
-p_sys-p_extra_buffer = malloc(buf_size);
-if (!p_sys-p_extra_buffer)
+p_sys-p_csd0_buffer = malloc(buf_size);
+if (!p_sys-p_csd0_buffer)
 {
 msg_Warn(p_dec, extra buffer allocation failed);
 goto error;
 }
 if (p_dec-fmt_in.i_codec == VLC_CODEC_H264  
((uint8_t*)p_dec-fmt_in.p_extra)[0] == 1) {
 convert_sps_pps(p_dec, p_dec-fmt_in.p_extra, 
p_dec-fmt_in.i_extra,
-p_sys-p_extra_buffer, buf_size,
+p_sys-p_csd0_buffer, buf_size,
 size, p_sys-nal_size);
 } else if (p_dec-fmt_in.i_codec == VLC_CODEC_HEVC) {
 convert_hevc_nal_units(p_dec, p_dec-fmt_in.p_extra,
p_dec-fmt_in.i_extra,
-   p_sys-p_extra_buffer, buf_size,
+   p_sys-p_csd0_buffer, buf_size,
size, p_sys-nal_size);
 } else {
-memcpy(p_sys-p_extra_buffer, p_dec-fmt_in.p_extra, size);
+memcpy(p_sys-p_csd0_buffer, p_dec-fmt_in.p_extra, size);
 }
-p_sys-i_extra_buffer = size;
+p_sys-i_csd0_buffer = size;
 }
-if (p_sys-p_extra_buffer)
+if (p_sys-p_csd0_buffer)
 {
-jobject jextra_buffer;
+jobject jcsd0_buffer;
 
-jextra_buffer = (*env)-NewDirectByteBuffer( env,
- p_sys-p_extra_buffer,
- p_sys-i_extra_buffer);
-if (CHECK_EXCEPTION() || !jextra_buffer)
+jcsd0_buffer = (*env)-NewDirectByteBuffer( env,
+p_sys-p_csd0_buffer,
+p_sys-i_csd0_buffer);
+if (CHECK_EXCEPTION() || !jcsd0_buffer)
 {
 msg_Warn(p_dec, java extra buffer allocation failed);
-free(p_sys-p_extra_buffer);
-p_sys-p_extra_buffer = NULL;
+free(p_sys-p_csd0_buffer);
+p_sys-p_csd0_buffer = NULL;
 goto error;
 }
 (*env)-CallVoidMethod(env, format, jfields.set_bytebuffer,
(*env)-NewStringUTF(env, csd-0),
-   jextra_buffer);
-(*env)-DeleteLocalRef(env, jextra_buffer);
+   jcsd0_buffer);
+(*env)-DeleteLocalRef(env, jcsd0_buffer);
 }
 
 p_sys-direct_rendering = var_InheritBool(p_dec, CFG_PREFIX dr);
@@ -803,7 +803,7 @@ static void CloseDecoder(vlc_object_t *p_this)
 else
 msg_Warn(p_dec, Can't get a JNIEnv, can't close mediacodec !);
 
-free(p_sys-p_extra_buffer);
+free(p_sys-p_csd0_buffer);
 free(p_sys-name);
 ArchitectureSpecificCopyHooksDestroy(p_sys-pixel_format, 
p_sys-architecture_specific_data);
 free(p_sys-pp_inflight_pictures);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: fix LocalRef leaks

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 11:45:46 
2015 +0200| [d5248dbb0c3f38f56099c18ca065b16c0650efb9] | committer: Thomas 
Guillem

mediacodec: fix LocalRef leaks

Now that we can open and close MediaCodec from the same thread, we can reach
quickly the limit of 512 LocalRefs.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d5248dbb0c3f38f56099c18ca065b16c0650efb9
---

 modules/codec/omxil/android_mediacodec.c |  150 +-
 1 file changed, 106 insertions(+), 44 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=d5248dbb0c3f38f56099c18ca065b16c0650efb9
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: add a second way to send codec specific data

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 09:28:36 
2015 +0200| [88c6f34a703d87e7aa942e5e00f1c39eec27f58e] | committer: Thomas 
Guillem

mediacodec: add a second way to send codec specific data

Via PutInput with the BUFFER_FLAG_CODEC_CONFIG flag. It allows to send codec
specific data during playback without restarting MediaCodec. If you choose to
configure codec via this flags, you shouldn't set the csd-0 buffer during
MediaCodec initialization.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88c6f34a703d87e7aa942e5e00f1c39eec27f58e
---

 modules/codec/omxil/android_mediacodec.c |   93 +-
 1 file changed, 67 insertions(+), 26 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 45fe7981..1b0c275 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -45,6 +45,8 @@
 #include android_opaque.h
 #include ../../video_output/android/android_window.h
 
+#define BUFFER_FLAG_CODEC_CONFIG  2
+
 #define INFO_OUTPUT_BUFFERS_CHANGED -3
 #define INFO_OUTPUT_FORMAT_CHANGED  -2
 #define INFO_TRY_AGAIN_LATER-1
@@ -142,8 +144,13 @@ struct decoder_sys_t
 int stride, slice_height;
 char *name;
 
+/* csd-0 buffer */
 void *p_csd0_buffer;
 size_t i_csd0_buffer;
+/* or buffer sent via BUFFER_FLAG_CODEC_CONFIG flag */
+uint8_t *p_config_buffer;
+size_t i_config_buffer;
+bool b_config_resend;
 
 bool allocated;
 bool started;
@@ -530,7 +537,11 @@ loopclean:
  jfields.create_video_format, 
(*env)-NewStringUTF(env, mime),
  p_dec-fmt_in.video.i_width, 
p_dec-fmt_in.video.i_height);
 
-if (p_dec-fmt_in.i_extra  !p_sys-p_csd0_buffer) {
+/* Either we use a csd-0 buffer that is provided before codec
+ * initialisation via the MediaFormat class, or use a CODEC_CONFIG buffer
+ * that can be provided during playback (and must be provided after a flush
+ * and a start). */
+if (p_dec-fmt_in.i_extra  !p_sys-p_config_buffer) {
 uint32_t size = p_dec-fmt_in.i_extra;
 int buf_size = p_dec-fmt_in.i_extra + 20;
 
@@ -804,6 +815,7 @@ static void CloseDecoder(vlc_object_t *p_this)
 msg_Warn(p_dec, Can't get a JNIEnv, can't close mediacodec !);
 
 free(p_sys-p_csd0_buffer);
+free(p_sys-p_config_buffer);
 free(p_sys-name);
 ArchitectureSpecificCopyHooksDestroy(p_sys-pixel_format, 
p_sys-architecture_specific_data);
 free(p_sys-pp_inflight_pictures);
@@ -900,10 +912,12 @@ static int PutInput(decoder_t *p_dec, JNIEnv *env, 
block_t *p_block, jlong timeo
 {
 decoder_sys_t *p_sys = p_dec-p_sys;
 int index;
-jobject buf;
-jsize size;
-uint8_t *bufptr;
-struct H264ConvertState convert_state = { 0, 0 };
+int64_t ts = 0;
+uint8_t *p_mc_buf, *p_buf;
+size_t i_buf;
+jobject j_mc_buf;
+jsize j_mc_size;
+jint j_flags = 0;
 
 index = (*env)-CallIntMethod(env, p_sys-codec,
   jfields.dequeue_input_buffer, timeout);
@@ -914,37 +928,60 @@ static int PutInput(decoder_t *p_dec, JNIEnv *env, 
block_t *p_block, jlong timeo
 if (index  0)
 return 0;
 
+if (p_sys-b_config_resend)
+{
+p_buf = p_sys-p_config_buffer;
+i_buf = p_sys-i_config_buffer;
+j_flags = BUFFER_FLAG_CODEC_CONFIG;
+msg_Dbg(p_dec, sending codec specific data of size %d 
+   via BUFFER_FLAG_CODEC_CONFIG flag, i_buf);
+} else
+{
+p_buf = p_block-p_buffer;
+i_buf = p_block-i_buffer;
+}
+
 if (jfields.get_input_buffers)
-buf = (*env)-GetObjectArrayElement(env, p_sys-input_buffers, index);
+j_mc_buf = (*env)-GetObjectArrayElement(env, p_sys-input_buffers,
+ index);
 else
-buf = (*env)-CallObjectMethod(env, p_sys-codec, 
jfields.get_input_buffer, index);
-size = (*env)-GetDirectBufferCapacity(env, buf);
-bufptr = (*env)-GetDirectBufferAddress(env, buf);
-if (size  0) {
+j_mc_buf = (*env)-CallObjectMethod(env, p_sys-codec,
+jfields.get_input_buffer, index);
+j_mc_size = (*env)-GetDirectBufferCapacity(env, j_mc_buf);
+p_mc_buf = (*env)-GetDirectBufferAddress(env, j_mc_buf);
+if (j_mc_size  0) {
 msg_Err(p_dec, Java buffer has invalid size);
 return -1;
 }
-if ((size_t) size  p_block-i_buffer)
-size = p_block-i_buffer;
-memcpy(bufptr, p_block-p_buffer, size);
-
-convert_h264_to_annexb(bufptr, size, p_sys-nal_size, convert_state);
-
-int64_t ts = p_block-i_pts;
-if (!ts  p_block-i_dts)
-ts = p_block-i_dts;
-if (p_block-i_flags  BLOCK_FLAG_PREROLL )
-p_sys-i_preroll_end = ts;
-timestamp_FifoPut(p_sys-timestamp_fifo, p_block-i_pts ? VLC_TS_INVALID : 
p_block-i_dts

[vlc-commits] packetizer h264: refactor and expose SPS/PPS parsing

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 18:24:38 
2015 +0200| [a56ed71a07144ea696b5e376073c00d226edea4d] | committer: Thomas 
Guillem

packetizer h264: refactor and expose SPS/PPS parsing

The goal is to expose h264_parse_sps and h264_parse_pps functions that can be
used from decoders.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a56ed71a07144ea696b5e376073c00d226edea4d
---

 modules/packetizer/h264.c |  306 +
 modules/packetizer/h264_nal.c |  281 +
 modules/packetizer/h264_nal.h |   58 
 3 files changed, 375 insertions(+), 270 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=a56ed71a07144ea696b5e376073c00d226edea4d
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] move h264/hevc nal helper code to packetizer

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 23 16:03:42 
2015 +0200| [6ea9e51b6b826fb4f8ad05fc82b186841a145f35] | committer: Thomas 
Guillem

move h264/hevc nal helper code to packetizer

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ea9e51b6b826fb4f8ad05fc82b186841a145f35
---

 modules/codec/Makefile.am|   11 ++-
 modules/codec/crystalhd.c|2 +-
 modules/codec/mft.c  |2 +-
 modules/codec/omxil/android_mediacodec.c |4 ++--
 modules/codec/omxil/omxil.c  |4 ++--
 modules/codec/omxil/utils.c  |2 +-
 modules/packetizer/Makefile.am   |2 +-
 modules/packetizer/h264.c|2 +-
 modules/{codec = packetizer}/h264_nal.c |0
 modules/{codec = packetizer}/h264_nal.h |0
 modules/{codec = packetizer}/hevc_nal.c |0
 modules/{codec = packetizer}/hevc_nal.h |0
 12 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index e5f7ed8..a81cdbf 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -375,8 +375,8 @@ noinst_HEADERS += \
 
 libomxil_plugin_la_SOURCES = \
codec/omxil/utils.c codec/omxil/omxil_utils.h \
-   codec/h264_nal.c codec/h264_nal.h \
-   codec/hevc_nal.c codec/hevc_nal.h \
+   packetizer/h264_nal.c packetizer/h264_nal.h \
+   packetizer/hevc_nal.c packetizer/hevc_nal.h \
codec/omxil/qcom.c codec/omxil/qcom.h \
codec/omxil/omxil.c codec/omxil/omxil.h codec/omxil/omxil_core.c 
codec/omxil/omxil_core.h \
video_chroma/copy.c
@@ -396,7 +396,8 @@ libiomx_plugin_la_LIBADD = $(libomxil_plugin_la_LIBADD)
 libmediacodec_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/codec/omxil
 libmediacodec_plugin_la_SOURCES = codec/omxil/android_mediacodec.c 
codec/omxil/utils.c \
video_chroma/copy.c codec/omxil/android_opaque.c 
codec/omxil/android_opaque.h \
-   codec/h264_nal.c codec/h264_nal.h codec/hevc_nal.c codec/hevc_nal.h
+   packetizer/h264_nal.c packetizer/h264_nal.h
+   packetizer/hevc_nal.c packetizer/hevc_nal.h
 
 codec_LTLIBRARIES += $(LTLIBomxil) $(LTLIBomxil_vout)
 EXTRA_LTLIBRARIES += libomxil_plugin.la libomxil_vout_plugin.la
@@ -474,7 +475,7 @@ codec_LTLIBRARIES += $(LTLIBtwolame)
 
 ### Hardware encoders ###
 
-libcrystalhd_plugin_la_SOURCES = codec/crystalhd.c codec/h264_nal.c 
codec/h264_nal.h
+libcrystalhd_plugin_la_SOURCES = codec/crystalhd.c packetizer/h264_nal.c 
packetizer/h264_nal.h
 libcrystalhd_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
 libcrystalhd_plugin_la_LIBADD = $(LIBS_crystalhd)
 EXTRA_LTLIBRARIES += libcrystalhd_plugin.la
@@ -498,7 +499,7 @@ libdmo_plugin_la_LIBADD += -lole32 -luuid
 codec_LTLIBRARIES += libdmo_plugin.la
 endif
 
-libmft_plugin_la_SOURCES = codec/mft.c codec/h264_nal.c codec/h264_nal.h
+libmft_plugin_la_SOURCES = codec/mft.c packetizer/h264_nal.c 
packetizer/h264_nal.h
 if HAVE_WIN32
 libmft_plugin_la_LIBADD = -lole32 -luuid -lmfuuid -lmfplat
 codec_LTLIBRARIES += libmft_plugin.la
diff --git a/modules/codec/crystalhd.c b/modules/codec/crystalhd.c
index b8e39af..d3b99ba 100644
--- a/modules/codec/crystalhd.c
+++ b/modules/codec/crystalhd.c
@@ -39,7 +39,7 @@
 #include vlc_common.h
 #include vlc_plugin.h
 #include vlc_codec.h
-#include h264_nal.h
+#include ../packetizer/h264_nal.h
 
 /* Workaround for some versions of libcrystalHD */
 #if !defined(_WIN32)  !defined(__APPLE__)
diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index 22e647f..8c9373a 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -42,7 +42,7 @@
 #include vlc_common.h
 #include vlc_plugin.h
 #include vlc_codec.h
-#include h264_nal.h
+#include ../packetizer/h264_nal.h
 #define _VIDEOINFOHEADER_
 #include vlc_codecs.h
 
diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 3e03c33..f98934d 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -37,8 +37,8 @@
 #include vlc_block_helper.h
 #include vlc_cpu.h
 
-#include ../h264_nal.h
-#include ../hevc_nal.h
+#include ../../packetizer/h264_nal.h
+#include ../../packetizer/hevc_nal.h
 #include OMX_Core.h
 #include OMX_Component.h
 #include omxil_utils.h
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 0176707..1418340 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -35,8 +35,8 @@
 #include vlc_codec.h
 #include vlc_block_helper.h
 #include vlc_cpu.h
-#include ../h264_nal.h
-#include ../hevc_nal.h
+#include ../../packetizer/h264_nal.h
+#include ../../packetizer/hevc_nal.h
 
 #include omxil.h
 #include omxil_core.h
diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 4ec6981..8263ad1 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -37,7 +37,7 @@
 #include omxil.h
 #include qcom.h
 #include ../../video_chroma

[vlc-commits] lib/video: set video prop to true when changing video tracks

2015-04-29 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr 28 18:38:58 
2015 +0200| [3add8370591bde4469720a368810fbd0e5e6e531] | committer: Thomas 
Guillem

lib/video: set video prop to true when changing video tracks

It allows an application to re-activate video when the media was played without
video (i.e. with :no-video).

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3add8370591bde4469720a368810fbd0e5e6e531
---

 lib/video.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/video.c b/lib/video.c
index 4abe36e..342247f 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -552,6 +552,8 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, 
int i_track )
 {
 if( i_track == val_list.p_list-p_values[i].i_int )
 {
+if( var_SetBool( p_input_thread, video, true )  0)
+break;
 if( var_SetInteger( p_input_thread, video-es, i_track )  0 )
 break;
 i_ret = 0;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: Add a define to fetch or not native sample rate

2015-04-29 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 29 10:17:10 
2015 +0200| [1f02594b331d532df0c394454393aeaf144f999b] | committer: Thomas 
Guillem

audiotrack: Add a define to fetch or not native sample rate

If activated, most of  the resampling  will be done by VLC.

Deactivated for now since android resampler is better than the ugly resampler.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1f02594b331d532df0c394454393aeaf144f999b
---

 modules/audio_output/audiotrack.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 0347aee..12fc84a 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -108,6 +108,10 @@ struct aout_sys_t {
 //#define AUDIOTRACK_USE_FLOAT
 //#define AUDIOTRACK_HW_LATENCY
 
+/* Get AudioTrack native sample rate: if activated, most of  the resampling
+ * will be done by VLC */
+//#define AUDIOTRACK_NATIVE_SAMPLERATE
+
 #define AUDIO_CHAN_TEXT N_(Audio output channels)
 #define AUDIO_CHAN_LONGTEXT N_(Channels available for audio output.  \
 If the input has more channels than the output, it will be down-mixed.  \
@@ -279,8 +283,10 @@ InitJNIFields( audio_output_t *p_aout )
 
 GET_ID( GetStaticMethodID, AudioTrack.getMinBufferSize, getMinBufferSize,
 (III)I, true );
+#ifdef AUDIOTRACK_NATIVE_SAMPLERATE
 GET_ID( GetStaticMethodID, AudioTrack.getNativeOutputSampleRate,
 getNativeOutputSampleRate,  (I)I, true );
+#endif
 GET_CONST_INT( AudioTrack.STATE_INITIALIZED, STATE_INITIALIZED, true );
 GET_CONST_INT( AudioTrack.MODE_STREAM, MODE_STREAM, true );
 GET_CONST_INT( AudioTrack.ERROR, ERROR, true );
@@ -831,7 +837,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 JNIEnv *env;
 jobject p_audiotrack = NULL;
 int i_nb_channels, i_max_channels, i_audiotrack_size, i_bytes_per_frame,
-i_native_rate;
+i_native_rate = 0;
 unsigned int i_rate;
 bool b_spdif;
 
@@ -853,13 +859,11 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 }
 else
 {
-i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
-
jfields.AudioManager.STREAM_MUSIC );
+if (jfields.AudioTrack.getNativeOutputSampleRate)
+i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
+
jfields.AudioManager.STREAM_MUSIC );
 if( i_native_rate = 0 )
-{
-msg_Warn( p_aout, negative native rate ? Should not happen ! );
 i_native_rate = VLC_CLIP( p_sys-fmt.i_rate, 4000, 48000 );
-}
 }
 
 /* We can only accept U8, S16N, FL32, and AC3 */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: negative delay can finally happen

2015-04-29 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 29 14:06:41 
2015 +0200| [57a878e66714c3752077a554923d86e380efd101] | committer: Thomas 
Guillem

audiotrack: negative delay can finally happen

It happens in case of underflow: if there is too much delay between two
consecutives call of Play or TimeGet.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=57a878e66714c3752077a554923d86e380efd101
---

 modules/audio_output/audiotrack.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 12fc84a..c4e5b14 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -690,7 +690,10 @@ TimeGet( audio_output_t *p_aout, mtime_t *restrict p_delay 
)
 return 0;
 }
 else
-msg_Warn( p_aout, Negative delay, Should not happen ! );
+{
+msg_Warn( p_aout, timing screwed, reset positions );
+AudioTrack_ResetPositions( env, p_aout );
+}
 }
 return -1;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] Fix build when using C99 and C++11

2015-04-30 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr 30 15:29:50 
2015 +0200| [51ce6cdaf598754e617900994c1943c6cba6d604] | committer: Thomas 
Guillem

Fix build when using C99 and C++11

Indeed, C99 doesn't have static_assert and C++11 has it.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51ce6cdaf598754e617900994c1943c6cba6d604
---

 include/vlc_fixups.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index b949d24..ee168d7 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -239,7 +239,7 @@ static inline locale_t newlocale(int mask, const char * 
locale, locale_t base)
 }
 #endif
 
-#if !defined (HAVE_STATIC_ASSERT)
+#if !defined (HAVE_STATIC_ASSERT)  !defined(__cpp_static_assert)
 # define _Static_assert(x, s) ((void) sizeof (struct { unsigned:-!(x); }))
 # define static_assert _Static_assert
 #endif

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: don't process output it input failed

2015-04-27 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 13:43:10 
2015 +0200| [c39c4bd3383478a2fcc890ab9c1f0ea8259db9e6] | committer: Thomas 
Guillem

mediacodec: don't process output it input failed

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c39c4bd3383478a2fcc890ab9c1f0ea8259db9e6
---

 modules/codec/omxil/android_mediacodec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index cf155dc..7672a2b 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1183,7 +1183,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 if (p_block  i_input_ret == 0)
 i_input_ret = PutInput(p_dec, env, p_block, timeout);
 
-if (i_output_ret == 0)
+if (i_input_ret != -1  i_output_ret == 0)
 {
 /* FIXME: A new picture shouldn't be created each time.
  * If decoder_NewPicture fails because the decoder is

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: remove invalid exception check

2015-04-27 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 27 14:06:14 
2015 +0200| [73d8e11f19944b7279c5ab3ec10ef5c3b90df7a9] | committer: Thomas 
Guillem

mediacodec: remove invalid exception check

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73d8e11f19944b7279c5ab3ec10ef5c3b90df7a9
---

 modules/codec/omxil/android_mediacodec.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 7672a2b..3e03c33 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1094,7 +1094,6 @@ static int GetOutput(decoder_t *p_dec, JNIEnv *env, 
picture_t *p_pic, jlong time
 p_sys-stride = width;
 if (p_sys-slice_height = 0)
 p_sys-slice_height = height;
-CHECK_EXCEPTION();
 
 ArchitectureSpecificCopyHooks(p_dec, p_sys-pixel_format, 
p_sys-slice_height,
   p_sys-stride, 
p_sys-architecture_specific_data);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] playlist/directory: fix wrong warning

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Mar 25 15:05:12 
2015 +0100| [437df0ea5ed3e94852ebc493fb0f1e2aebc26d20] | committer: Thomas 
Guillem

playlist/directory: fix wrong warning

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=437df0ea5ed3e94852ebc493fb0f1e2aebc26d20
---

 modules/demux/playlist/directory.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/demux/playlist/directory.c 
b/modules/demux/playlist/directory.c
index a73a138..9b7ffc2 100644
--- a/modules/demux/playlist/directory.c
+++ b/modules/demux/playlist/directory.c
@@ -69,11 +69,10 @@ static int Demux( demux_t *p_demux )
 
 if( stream_ReadDir( p_demux-s, p_node ) )
 {
+msg_Warn( p_demux, unable to read directory );
 input_item_node_Delete( p_node );
 return VLC_EGENERIC;
 }
-else
-msg_Warn( p_demux, unable to read directory );
 
 input_item_node_PostAndDelete( p_node );
 return VLC_SUCCESS;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] ftp: fix crash when accessing default directory

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Sun May  3 16:36:29 
2015 +| [54551b5c65a3bc0cf0e07d477d773c6f9b3f27d2] | committer: Thomas 
Guillem

ftp: fix crash when accessing default directory

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=54551b5c65a3bc0cf0e07d477d773c6f9b3f27d2
---

 modules/access/ftp.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index e9eb77b..fa22a20 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -537,7 +537,8 @@ static int Connect( vlc_object_t *p_access, access_sys_t 
*p_sys )
 goto error;
 }
 
-if( (p_sys-features.b_unicode ? IsUTF8 : IsASCII)(p_sys-url.psz_path) == 
NULL )
+if( p_sys-url.psz_path 
+(p_sys-features.b_unicode ? IsUTF8 : IsASCII)(p_sys-url.psz_path) == 
NULL )
 {
 msg_Err( p_access, unsupported path: \%s\, p_sys-url.psz_path );
 goto error;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] access: pf_control is not mandatory for directory accesses

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon May  4 09:11:08 
2015 +0200| [763e765d2446cc87380a342a4f450f44a1bf89d3] | committer: Thomas 
Guillem

access: pf_control is not mandatory for directory accesses

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=763e765d2446cc87380a342a4f450f44a1bf89d3
---

 include/vlc_access.h|3 ++-
 modules/access/directory.c  |   30 --
 modules/access/dsm/access.c |   27 ---
 modules/access/sftp.c   |   28 
 modules/services_discovery/upnp.cpp |   31 ---
 src/input/access.c  |5 +
 6 files changed, 7 insertions(+), 117 deletions(-)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index e83d53f..1f3cb03 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -117,7 +117,8 @@ struct access_t
 static inline int access_vaControl( access_t *p_access, int i_query, va_list 
args )
 {
 if( !p_access ) return VLC_EGENERIC;
-return p_access-pf_control( p_access, i_query, args );
+return p_access-pf_control ? p_access-pf_control( p_access, i_query, 
args )
+: VLC_EGENERIC;
 }
 
 static inline int access_Control( access_t *p_access, int i_query, ... )
diff --git a/modules/access/directory.c b/modules/access/directory.c
index 7209978..5cac748 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -327,7 +327,6 @@ int DirInit (access_t *p_access, DIR *handle)
 p_sys-ignored_exts = var_InheritString (p_access, ignore-filetypes);
 
 p_access-pf_readdir = DirRead;
-p_access-pf_control = DirControl;
 
 return VLC_SUCCESS;
 
@@ -417,32 +416,3 @@ int DirRead (access_t *p_access, input_item_node_t 
*p_current_node)
 
 return VLC_SUCCESS;
 }
-
-/*
- * Control:
- */
-int DirControl (access_t *p_access, int i_query, va_list args)
-{
-VLC_UNUSED (p_access);
-
-switch (i_query)
-{
-case ACCESS_CAN_SEEK:
-case ACCESS_CAN_FASTSEEK:
-*va_arg (args, bool*) = false;
-break;
-
-case ACCESS_CAN_PAUSE:
-case ACCESS_CAN_CONTROL_PACE:
-*va_arg (args, bool*) = true;
-break;
-
-case ACCESS_GET_PTS_DELAY:
-*va_arg (args, int64_t *) = DEFAULT_PTS_DELAY * 1000;
-break;
-
-default:
-return VLC_EGENERIC;
- }
- return VLC_SUCCESS;
- }
diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
index d6c83f6..5695718 100644
--- a/modules/access/dsm/access.c
+++ b/modules/access/dsm/access.c
@@ -692,32 +692,6 @@ static int BrowseDirectory( access_t *p_access, 
input_item_node_t *p_node )
 return i_ret;
 }
 
-static int BrowserControl( access_t *p_access, int i_query, va_list args )
-{
-VLC_UNUSED( p_access );
-
-switch( i_query )
-{
-case ACCESS_CAN_SEEK:
-case ACCESS_CAN_FASTSEEK:
-*va_arg( args, bool* ) = false;
-break;
-
-case ACCESS_CAN_PAUSE:
-case ACCESS_CAN_CONTROL_PACE:
-*va_arg( args, bool* ) = true;
-break;
-
-case ACCESS_GET_PTS_DELAY:
-*va_arg( args, int64_t * ) = DEFAULT_PTS_DELAY * 1000;
-break;
-
-default:
-return VLC_EGENERIC;
- }
- return VLC_SUCCESS;
-}
-
 static int BrowserInit( access_t *p_access )
 {
 access_sys_t *p_sys = p_access-p_sys;
@@ -726,7 +700,6 @@ static int BrowserInit( access_t *p_access )
 p_access-pf_readdir = BrowseShare;
 else
 p_access-pf_readdir = BrowseDirectory;
-p_access-pf_control = BrowserControl;
 
 return VLC_SUCCESS;
 }
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 3a59fd2..43edca1 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -272,7 +272,6 @@ static int Open( vlc_object_t* p_this )
 p_sys-file = libssh2_sftp_opendir( p_sys-sftp_session, url.psz_path 
);
 
 p_access-pf_readdir = DirRead;
-p_access-pf_control = DirControl;
 
 if( p_sys-file )
 {
@@ -506,30 +505,3 @@ static int DirRead (access_t *p_access, input_item_node_t 
*p_current_node)
 free( psz_file );
 return VLC_SUCCESS;
 }
-
-
-static int DirControl( access_t *p_access, int i_query, va_list args )
-{
-VLC_UNUSED( p_access );
-
-switch( i_query )
-{
-case ACCESS_CAN_SEEK:
-case ACCESS_CAN_FASTSEEK:
-*va_arg( args, bool* ) = false;
-break;
-
-case ACCESS_CAN_PAUSE:
-case ACCESS_CAN_CONTROL_PACE:
-*va_arg( args, bool* ) = true;
-break;
-
-case ACCESS_GET_PTS_DELAY:
-*va_arg( args, int64_t * ) = DEFAULT_PTS_DELAY * 1000;
-break;
-
-default:
-return

[vlc-commits] ftp: implement readdir

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Sun May  3 16:36:30 
2015 +| [eba42da6c0ec550ceca1570c554ee854ee7773fd] | committer: Thomas 
Guillem

ftp: implement readdir

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eba42da6c0ec550ceca1570c554ee854ee7773fd
---

 modules/access/ftp.c |   94 +++---
 1 file changed, 58 insertions(+), 36 deletions(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index fa22a20..273e5fc 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -37,6 +37,7 @@
 
 #include vlc_access.h
 #include vlc_dialog.h
+#include vlc_input_item.h
 
 #include vlc_network.h
 #include vlc_url.h
@@ -105,6 +106,7 @@ vlc_module_end ()
 static ssize_t Read( access_t *, uint8_t *, size_t );
 static int Seek( access_t *, uint64_t );
 static int Control( access_t *, int, va_list );
+static int DirRead( access_t *, input_item_node_t * );
 #ifdef ENABLE_SOUT
 static int OutSeek( sout_access_out_t *, off_t );
 static ssize_t Write( sout_access_out_t *, block_t * );
@@ -141,7 +143,6 @@ struct access_sys_t
 
 char   sz_epsv_ip[NI_MAXNUMERICHOST];
 bool   out;
-bool   directory;
 uint64_t   size;
 };
 #define GET_OUT_SYS( p_this ) \
@@ -263,7 +264,7 @@ static int ftp_RecvCommand( vlc_object_t *obj, access_sys_t 
*sys,
 return ftp_RecvAnswer( obj, sys, codep, strp, DummyLine, NULL );
 }
 
-static int ftp_StartStream( vlc_object_t *, access_sys_t *, uint64_t );
+static int ftp_StartStream( vlc_object_t *, access_sys_t *, uint64_t, bool );
 static int ftp_StopStream ( vlc_object_t *, access_sys_t * );
 
 static void readTLSMode( access_sys_t *p_sys, const char * psz_access )
@@ -614,12 +615,15 @@ static int InOpen( vlc_object_t *p_this )
 access_t *p_access = (access_t*)p_this;
 access_sys_t *p_sys;
 char *psz_arg;
+bool  b_directory = false;
 
 /* Init p_access */
-STANDARD_READ_ACCESS_INIT
+access_InitFields( p_access );
+p_sys = p_access-p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) 
);
+if( !p_sys )
+return VLC_ENOMEM;
 p_sys-data.fd = -1;
 p_sys-out = false;
-p_sys-directory = false;
 p_sys-size = 0;
 readTLSMode( p_sys, p_access-psz_access );
 
@@ -631,7 +635,7 @@ static int InOpen( vlc_object_t *p_this )
 
 /* get size */
 if( p_sys-url.psz_path == NULL )
-p_sys-directory = true;
+b_directory = true;
 else
 if( ftp_SendCommand( p_this, p_sys, SIZE %s, p_sys-url.psz_path )  0 )
 goto error;
@@ -652,10 +656,15 @@ static int InOpen( vlc_object_t *p_this )
 goto error;
 }
 else
-p_sys-directory = true;
+b_directory = true;
+
+if( b_directory )
+p_access-pf_readdir = DirRead;
+else
+ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
 
 /* Start the 'stream' */
-if( ftp_StartStream( p_this, p_sys, 0 )  0 )
+if( ftp_StartStream( p_this, p_sys, 0, b_directory )  0 )
 {
 msg_Err( p_this, cannot retrieve file );
 clearCmdTLS( p_sys );
@@ -702,7 +711,7 @@ static int OutOpen( vlc_object_t *p_this )
 goto exit_error;
 
 /* Start the 'stream' */
-if( ftp_StartStream( p_this, p_sys, 0 )  0 )
+if( ftp_StartStream( p_this, p_sys, 0, false )  0 )
 {
 msg_Err( p_access, cannot store file );
 clearCmdTLS( p_sys );
@@ -769,7 +778,7 @@ static int _Seek( vlc_object_t *p_access, access_sys_t 
*p_sys, uint64_t i_pos )
 msg_Dbg( p_access, seeking to %PRIu64, i_pos );
 
 ftp_StopStream( (vlc_object_t *)p_access, p_sys );
-if( ftp_StartStream( (vlc_object_t *)p_access, p_sys, i_pos )  0 )
+if( ftp_StartStream( (vlc_object_t *)p_access, p_sys, i_pos, false )  0 )
 return VLC_EGENERIC;
 
 return VLC_SUCCESS;
@@ -800,6 +809,7 @@ static int OutSeek( sout_access_out_t *p_access, off_t 
i_pos )
 static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
 {
 access_sys_t *p_sys = p_access-p_sys;
+int i_read;
 
 assert( p_sys-data.fd != -1 );
 assert( !p_sys-out );
@@ -807,36 +817,48 @@ static ssize_t Read( access_t *p_access, uint8_t 
*p_buffer, size_t i_len )
 if( p_access-info.b_eof )
 return 0;
 
-if( p_sys-directory )
+i_read = net_Read( p_access, p_sys-data.fd, p_sys-data.p_vs,
+   p_buffer, i_len, false );
+if( i_read == 0 )
+p_access-info.b_eof = true;
+else if( i_read  0 )
+p_access-info.i_pos += i_read;
+
+return i_read;
+}
+
+/*
+ * DirRead:
+ */
+static int DirRead (access_t *p_access, input_item_node_t *p_current_node)
+{
+access_sys_t *p_sys = p_access-p_sys;
+char *psz_line;
+
+assert( p_sys-data.fd != -1 );
+assert( !p_sys-out );
+
+while( ( psz_line

[vlc-commits] ftp: fix readdir in default directory

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Sun May  3 16:36:31 
2015 +| [6ecd2a42548e6be7a1bcad20abc24fbc08a7d041] | committer: Thomas 
Guillem

ftp: fix readdir in default directory

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ecd2a42548e6be7a1bcad20abc24fbc08a7d041
---

 modules/access/ftp.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 273e5fc..7d3f19d 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -842,11 +842,13 @@ static int DirRead (access_t *p_access, input_item_node_t 
*p_current_node)
 {
 char *psz_uri;
 
-if( asprintf( psz_uri, %s://%s:%d/%s/%s,
+if( asprintf( psz_uri, %s://%s:%d%s%s/%s,
   ( p_sys-tlsmode == NONE ) ? ftp :
   ( ( p_sys-tlsmode == IMPLICIT ) ? ftps : ftpes ),
   p_sys-url.psz_host, p_sys-url.i_port,
-  p_sys-url.psz_path, psz_line ) != -1 )
+  p_sys-url.psz_path ? / : ,
+  p_sys-url.psz_path ? p_sys-url.psz_path : ,
+  psz_line ) != -1 )
 {
 input_item_t *p_item;
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: factor i_nb_channels

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon May  4 16:25:08 
2015 +0200| [d54ef066c2279b735922445b9310fc0d9ba35d7a] | committer: Thomas 
Guillem

audiotrack: factor i_nb_channels

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d54ef066c2279b735922445b9310fc0d9ba35d7a
---

 modules/audio_output/audiotrack.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index c4e5b14..fb3e517 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -912,10 +912,10 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 else
 p_sys-fmt.i_physical_channels = AOUT_CHANS_STEREO;
 }
-i_nb_channels = aout_FormatNbChannels( p_sys-fmt );
 
 do
 {
+i_nb_channels = aout_FormatNbChannels( p_sys-fmt );
 i_bytes_per_frame = i_nb_channels *
 aout_BitsPerSample( p_sys-fmt.i_format ) / 8;
 i_rate = p_sys-fmt.i_format == VLC_CODEC_SPDIFB ?
@@ -953,7 +953,6 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 msg_Warn( p_aout, 5.1 or 7.1 configuration failed, 
   fallback to Stereo );
 p_sys-fmt.i_physical_channels = AOUT_CHANS_STEREO;
-i_nb_channels = aout_FormatNbChannels( p_sys-fmt );
 }
 else
 break;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: put back vlc resampler

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon May  4 16:25:26 
2015 +0200| [d95c61247eb9b1102cb5fa13361b87390095d839] | committer: Thomas 
Guillem

audiotrack: put back vlc resampler

Some devices fail to resample uncommon rates (like 22050Hz).

Fixes #14514

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d95c61247eb9b1102cb5fa13361b87390095d839
---

 modules/audio_output/audiotrack.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index fb3e517..55c975f 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -110,7 +110,7 @@ struct aout_sys_t {
 
 /* Get AudioTrack native sample rate: if activated, most of  the resampling
  * will be done by VLC */
-//#define AUDIOTRACK_NATIVE_SAMPLERATE
+#define AUDIOTRACK_NATIVE_SAMPLERATE
 
 #define AUDIO_CHAN_TEXT N_(Audio output channels)
 #define AUDIO_CHAN_LONGTEXT N_(Channels available for audio output.  \

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] ftp: fix item leak and check error

2015-05-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon May  4 17:43:15 
2015 +0200| [ec83163133cdfc85901d1826c3b482bde28631ea] | committer: Thomas 
Guillem

ftp: fix item leak and check error

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ec83163133cdfc85901d1826c3b482bde28631ea
---

 modules/access/ftp.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 7d3f19d..8a52231 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -854,9 +854,15 @@ static int DirRead (access_t *p_access, input_item_node_t 
*p_current_node)
 
 p_item = input_item_NewWithTypeExt( psz_uri, psz_line, 0, NULL,
 0, -1, ITEM_TYPE_UNKNOWN, 1 );
+free( psz_uri );
+if( !p_item )
+{
+free( psz_line );
+return VLC_ENOMEM;
+}
 input_item_CopyOptions( p_current_node-p_item, p_item );
 input_item_node_AppendItem( p_current_node, p_item );
-free( psz_uri );
+input_item_Release( p_item );
 }
 free( psz_line );
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] fix dxva2 build

2015-04-28 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr 28 17:54:25 
2015 +0200| [8f433b2594e434c569a88eea653f432c4874a202] | committer: Thomas 
Guillem

fix dxva2 build

A wise man once said: always do a make distcheck when you move some files

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8f433b2594e434c569a88eea653f432c4874a202
---

 modules/codec/Makefile.am |2 +-
 modules/codec/avcodec/dxva2.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index a81cdbf..bd89326 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -342,7 +342,7 @@ endif
 
 libdxva2_plugin_la_SOURCES = \
video_chroma/copy.c video_chroma/copy.h \
-   codec/avcodec/dxva2.c codec/h264_nal.c codec/h264_nal.h
+   codec/avcodec/dxva2.c packetizer/h264_nal.c packetizer/h264_nal.h
 libdxva2_plugin_la_LIBADD = -lole32 -lshlwapi -luuid
 if HAVE_AVCODEC_DXVA2
 codec_LTLIBRARIES += libdxva2_plugin.la
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 482810c..52b40bd 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -51,7 +51,7 @@
 #include avcodec.h
 #include va.h
 #include ../../video_chroma/copy.h
-#include ../h264_nal.h
+#include ../../packetizer/h264_nal.h
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
 const es_format_t *, picture_sys_t *p_sys);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] demux/playlist: ensure that a playlist is a file

2015-05-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu May  7 16:55:01 
2015 +0200| [dc39e0ea3066898e67c67d3b4004f0fe869ac3d4] | committer: Thomas 
Guillem

demux/playlist: ensure that a playlist is a file

A lot of playlist probe only check the file extension that returns true for a
directory too.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc39e0ea3066898e67c67d3b4004f0fe869ac3d4
---

 modules/demux/playlist/asx.c   |1 +
 modules/demux/playlist/b4s.c   |1 +
 modules/demux/playlist/dvb.c   |5 +++--
 modules/demux/playlist/gvp.c   |1 +
 modules/demux/playlist/ifo.c   |1 +
 modules/demux/playlist/m3u.c   |1 +
 modules/demux/playlist/playlist.h  |   10 ++
 modules/demux/playlist/pls.c   |1 +
 modules/demux/playlist/podcast.c   |1 +
 modules/demux/playlist/qtl.c   |1 +
 modules/demux/playlist/ram.c   |1 +
 modules/demux/playlist/sgimb.c |1 +
 modules/demux/playlist/shoutcast.c |1 +
 modules/demux/playlist/wpl.c   |2 ++
 14 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c
index 6f6e666..cd93692 100644
--- a/modules/demux/playlist/asx.c
+++ b/modules/demux/playlist/asx.c
@@ -145,6 +145,7 @@ int Import_ASX( vlc_object_t *p_this )
 {
 demux_t *p_demux = (demux_t *)p_this;
 
+CHECK_FILE();
 if( demux_IsPathExtension( p_demux, .asx ) ||
 demux_IsPathExtension( p_demux, .wax ) ||
 demux_IsPathExtension( p_demux, .wvx ) ||
diff --git a/modules/demux/playlist/b4s.c b/modules/demux/playlist/b4s.c
index d9c0465..cea6d85 100644
--- a/modules/demux/playlist/b4s.c
+++ b/modules/demux/playlist/b4s.c
@@ -49,6 +49,7 @@ int Import_B4S( vlc_object_t *p_this )
 {
 demux_t *demux = (demux_t *)p_this;
 
+CHECK_FILE();
 if( !demux_IsPathExtension( demux, .b4s )
   !demux_IsForced( demux, b4s-open ) )
 return VLC_EGENERIC;
diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c
index 0b5e796..94289a4 100644
--- a/modules/demux/playlist/dvb.c
+++ b/modules/demux/playlist/dvb.c
@@ -42,10 +42,11 @@ static int Demux(demux_t *);
 static input_item_t *ParseLine(char *line);
 
 /** Detect dvb-utils zap channels.conf format */
-int Import_DVB(vlc_object_t *obj)
+int Import_DVB(vlc_object_t *p_this)
 {
-demux_t *demux = (demux_t *)obj;
+demux_t *demux = (demux_t *)p_this;
 
+CHECK_FILE();
 if (!demux_IsPathExtension(demux, .conf )  !demux-b_force )
 return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/gvp.c b/modules/demux/playlist/gvp.c
index e28e09b..2eca158 100644
--- a/modules/demux/playlist/gvp.c
+++ b/modules/demux/playlist/gvp.c
@@ -73,6 +73,7 @@ int Import_GVP( vlc_object_t *p_this )
 int i_peek, i, b_found = false;
 const uint8_t *p_peek;
 
+CHECK_FILE();
 i_peek = stream_Peek( p_demux-s, p_peek, MAX_LINE );
 
 for( i = 0; i  i_peek - (int)sizeof(gvp_version:); i++ )
diff --git a/modules/demux/playlist/ifo.c b/modules/demux/playlist/ifo.c
index e031f8b..7d3bf4f 100644
--- a/modules/demux/playlist/ifo.c
+++ b/modules/demux/playlist/ifo.c
@@ -47,6 +47,7 @@ int Import_IFO( vlc_object_t *p_this )
 {
 demux_t *p_demux = (demux_t *)p_this;
 
+CHECK_FILE();
 if( !p_demux-psz_file )
 return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index 02a9598..a0572ff 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -69,6 +69,7 @@ int Import_M3U( vlc_object_t *p_this )
 char *(*pf_dup) (const char *) = GuessEncoding;
 int offset = 0;
 
+CHECK_FILE();
 if( stream_Peek( p_demux-s, p_peek, 3 ) == 3
   !memcmp( p_peek, \xef\xbb\xbf, 3) )
 {
diff --git a/modules/demux/playlist/playlist.h 
b/modules/demux/playlist/playlist.h
index 64245f2..ea6ef4b 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -82,24 +82,34 @@ extern input_item_t * GetCurrentItem(demux_t *p_demux);
 
 bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
 
+#define CHECK_FILE() do { \
+bool b_is_dir = false; \
+stream_Control( ((demux_t *)p_this)-s, STREAM_IS_DIRECTORY, b_is_dir ); \
+if( b_is_dir ) \
+return VLC_EGENERIC; \
+} while(0)
+
 #define STANDARD_DEMUX_INIT_MSG( msg ) do { \
 DEMUX_INIT_COMMON();\
 msg_Dbg( p_demux, %s, msg ); } while(0)
 
 #define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
 demux_t *p_demux = (demux_t *)p_this; \
+CHECK_FILE(); \
 if( !demux_IsPathExtension( p_demux, ext ) ) \
 return VLC_EGENERIC; \
 STANDARD_DEMUX_INIT_MSG( msg );
 
 #define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
 demux_t *p_demux = (demux_t *)p_this; \
+CHECK_FILE(); \
 if( !demux_IsPathExtension( p_demux, ext )  !demux_IsForced( p_demux, 
module ) ) \
 return VLC_EGENERIC; \
 STANDARD_DEMUX_INIT_MSG( msg

[vlc-commits] mediacodec: change the way to send codec specific data

2015-05-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue May 12 17:12:37 
2015 +0200| [44b32150804365f85eb7606146ee52496e6e8b79] | committer: Thomas 
Guillem

mediacodec: change the way to send codec specific data

The CSD is now split into several ones, therefore there is one CSD per H264
Parameter Sets (SPS and PPS).

There is now only one way to send a CSD. It's sent via PutInput with the
BUFFER_FLAG_CODEC_CONFIG flag.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=44b32150804365f85eb7606146ee52496e6e8b79
---

 modules/codec/omxil/android_mediacodec.c |  356 +-
 1 file changed, 203 insertions(+), 153 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=44b32150804365f85eb7606146ee52496e6e8b79
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: move restart handling in DecodeVideo

2015-05-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue May 12 18:10:18 
2015 +0200| [fb43d75f9b3bbfd41c6ad6d2f7babbd0e59089ce] | committer: Thomas 
Guillem

mediacodec: move restart handling in DecodeVideo

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fb43d75f9b3bbfd41c6ad6d2f7babbd0e59089ce
---

 modules/codec/omxil/android_mediacodec.c |   43 +-
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 740c124..4d1757d 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1344,12 +1344,11 @@ static int GetOutput(decoder_t *p_dec, JNIEnv *env, 
picture_t *p_pic, jlong time
 return 0;
 }
 
-static void H264ProcessBlock(decoder_t *p_dec, JNIEnv *env, block_t *p_block,
- bool *p_delayed_open)
+static void H264ProcessBlock(decoder_t *p_dec, block_t *p_block,
+ bool *p_csd_changed, bool *p_size_changed)
 {
 decoder_sys_t *p_sys = p_dec-p_sys;
 struct H264ConvertState convert_state = { 0, 0 };
-bool b_size_changed;
 
 assert(p_dec-fmt_in.i_codec == VLC_CODEC_H264  p_block);
 
@@ -1358,22 +1357,14 @@ static void H264ProcessBlock(decoder_t *p_dec, JNIEnv 
*env, block_t *p_block,
 convert_h264_to_annexb(p_block-p_buffer, p_block-i_buffer,
p_sys-nal_size, convert_state);
 } else if (H264SetCSD(p_dec, p_block-p_buffer, p_block-i_buffer,
-  b_size_changed) == VLC_SUCCESS)
+  p_size_changed) == VLC_SUCCESS)
 {
-if (p_sys-codec  b_size_changed)
-{
-msg_Err(p_dec, SPS/PPS changed during playback and 
-MediaCodec configured with a different video size. 
-Restart it !);
-CloseMediaCodec(p_dec, env);
-}
-if (!p_sys-codec)
-*p_delayed_open = true;
+*p_csd_changed = true;
 }
 }
 
-static void HEVCProcessBlock(decoder_t *p_dec, JNIEnv *env, block_t *p_block,
- bool *p_delayed_open)
+static void HEVCProcessBlock(decoder_t *p_dec, block_t *p_block,
+ bool *p_csd_changed, bool *p_size_changed)
 {
 decoder_sys_t *p_sys = p_dec-p_sys;
 struct H264ConvertState convert_state = { 0, 0 };
@@ -1387,8 +1378,8 @@ static void HEVCProcessBlock(decoder_t *p_dec, JNIEnv 
*env, block_t *p_block,
 }
 
 /* TODO */
-VLC_UNUSED(env);
-VLC_UNUSED(p_delayed_open);
+VLC_UNUSED(p_csd_changed);
+VLC_UNUSED(p_size_changed);
 }
 
 static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block)
@@ -1450,11 +1441,25 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 
 if (b_new_block)
 {
+bool b_csd_changed = false, b_size_changed = false;
+
 p_sys-b_new_block = false;
 if (p_dec-fmt_in.i_codec == VLC_CODEC_H264)
-H264ProcessBlock(p_dec, env, p_block, b_delayed_open);
+H264ProcessBlock(p_dec, p_block, b_csd_changed, b_size_changed);
 else if (p_dec-fmt_in.i_codec == VLC_CODEC_HEVC)
-HEVCProcessBlock(p_dec, env, p_block, b_delayed_open);
+HEVCProcessBlock(p_dec, p_block, b_csd_changed, b_size_changed);
+
+if (p_sys-codec  b_csd_changed)
+{
+if (b_size_changed)
+{
+msg_Err(p_dec, SPS/PPS changed during playback and 
+video size are different. Restart it !);
+CloseMediaCodec(p_dec, env);
+}
+}
+if (!p_sys-codec)
+b_delayed_open = true;
 }
 
 /* try delayed opening if there is a new extra data */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: more verbose in case of error

2015-05-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed May 13 11:22:59 
2015 +0200| [0d92b77532efd9338334be8690f33d0459f3b81f] | committer: Thomas 
Guillem

mediacodec: more verbose in case of error

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0d92b77532efd9338334be8690f33d0459f3b81f
---

 modules/codec/omxil/android_mediacodec.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 42014e5..0c70b6c 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1603,6 +1603,8 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
  * indefinitely and abort after 2seconds (100 * 2 * 10ms)
  * without any data. Indeed, MediaCodec can fail without
  * throwing any exception or error returns... */
+msg_Err(p_dec, No output/input for %lld ms, abort,
+i_attempts * timeout);
 b_error = true;
 break;
 }
@@ -1615,7 +1617,11 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 } while (p_block  i_input_ret == 0  i_output_ret == 0);
 
 if (i_input_ret == -1 || i_output_ret == -1)
+{
+msg_Err(p_dec, %s failed,
+i_input_ret == -1 ? PutInput : GetOutput);
 b_error = true;
+}
 
 endclean:
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: handle HW latency

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 15 12:04:45 
2015 +0200| [985ff5cb03d483d034aa7a2192705f5835b760dc] | committer: Thomas 
Guillem

audiotrack: handle HW latency

Since Android 4.3 there is a hidden method that retrieve the audio hardware
latency: AudioSystem.getOutputLatency() (that should not be used according to
the android comments).

This latency should not be used when we use AudioTrack.getTimestamp since it
already take into account the hardware latency. So why adding a new method ?
Because AudioTrack.getTimestamp don't work with Bluetooth (it returns false).

This fix lip sync with Bluetooth audio.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=985ff5cb03d483d034aa7a2192705f5835b760dc
---

 modules/audio_output/audiotrack.c |   28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index c2c06c3..14a6e53 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -83,6 +83,7 @@ struct aout_sys_t {
 mtime_t p_us[SMOOTHPOS_SAMPLE_COUNT];
 mtime_t i_us;
 mtime_t i_last_time;
+mtime_t i_latency_us;
 } smoothpos;
 
 uint64_t i_samples_written; /* number of samples written since last flush 
*/
@@ -183,6 +184,10 @@ static struct
 } AudioManager;
 struct {
 jclass clazz;
+jmethodID getOutputLatency;
+} AudioSystem;
+struct {
+jclass clazz;
 jmethodID ctor;
 jfieldID framePosition;
 jfieldID nanoTime;
@@ -297,6 +302,15 @@ InitJNIFields( audio_output_t *p_aout )
 nanoTime, J, true );
 }
 
+/* AudioSystem class init */
+GET_CLASS( android/media/AudioSystem, false );
+if( clazz )
+{
+jfields.AudioSystem.clazz = (jclass) (*env)-NewGlobalRef( env, clazz 
);
+GET_ID( GetStaticMethodID, AudioSystem.getOutputLatency,
+getOutputLatency, (I)I, false );
+}
+
 /* AudioFormat class init */
 GET_CLASS( android/media/AudioFormat, true );
 GET_CONST_INT( AudioFormat.ENCODING_PCM_8BIT, ENCODING_PCM_8BIT, true );
@@ -507,6 +521,7 @@ AudioTrack_ResetPositions( JNIEnv *env, audio_output_t 
*p_aout )
 p_sys-smoothpos.i_idx = 0;
 p_sys-smoothpos.i_last_time = 0;
 p_sys-smoothpos.i_us = 0;
+p_sys-smoothpos.i_latency_us = 0;
 }
 
 /**
@@ -541,9 +556,20 @@ AudioTrack_GetSmoothPositionUs( JNIEnv *env, 
audio_output_t *p_aout )
 for( uint32_t i = 0; i  p_sys-smoothpos.i_count; ++i )
 p_sys-smoothpos.i_us += p_sys-smoothpos.p_us[i];
 p_sys-smoothpos.i_us /= p_sys-smoothpos.i_count;
+
+if( jfields.AudioSystem.getOutputLatency )
+{
+int i_latency_ms = JNI_CALL( CallStaticIntMethod,
+ jfields.AudioSystem.clazz,
+ jfields.AudioSystem.getOutputLatency,
+ jfields.AudioManager.STREAM_MUSIC );
+
+p_sys-smoothpos.i_latency_us = i_latency_ms  0 ?
+i_latency_ms * 1000L : 0;
+}
 }
 if( p_sys-smoothpos.i_us != 0 )
-return p_sys-smoothpos.i_us + i_now;
+return p_sys-smoothpos.i_us + i_now - p_sys-smoothpos.i_latency_us;
 else
 return 0;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: smooth out the AudioTrack position

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr 14 19:49:56 
2015 +0200| [b50b9c35a75fcef1549e55607ef1c0044d2e1fb1] | committer: Thomas 
Guillem

audiotrack: smooth out the AudioTrack position

It improves delay precision for old devices.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b50b9c35a75fcef1549e55607ef1c0044d2e1fb1
---

 modules/audio_output/audiotrack.c |   67 -
 1 file changed, 59 insertions(+), 8 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 3c5f1ae..c2c06c3 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -37,6 +37,9 @@
 #define MIN_AUDIOTRACK_BUFFER_US INT64_C(25)  // 250ms
 #define MAX_AUDIOTRACK_BUFFER_US INT64_C(100) // 1000ms
 
+#define SMOOTHPOS_SAMPLE_COUNT 10
+#define SMOOTHPOS_INTERVAL_US INT64_C(3) // 30ms
+
 #define AUDIOTIMESTAMP_INTERVAL_US INT64_C(50) // 500ms
 
 static int  Open( vlc_object_t * );
@@ -73,6 +76,15 @@ struct aout_sys_t {
 mtime_t i_last_time;
 } timestamp;
 
+/* Used by AudioTrack_GetSmoothPositionUs */
+struct {
+uint32_t i_idx;
+uint32_t i_count;
+mtime_t p_us[SMOOTHPOS_SAMPLE_COUNT];
+mtime_t i_us;
+mtime_t i_last_time;
+} smoothpos;
+
 uint64_t i_samples_written; /* number of samples written since last flush 
*/
 uint32_t i_bytes_per_frame; /* byte per frame */
 uint32_t i_max_audiotrack_samples;
@@ -478,7 +490,7 @@ AudioTrack_ResetPlaybackHeadPosition( JNIEnv *env, 
audio_output_t *p_aout )
 }
 
 /**
- * Reset AudioTrack Position
+ * Reset AudioTrack SmoothPosition and TimestampPosition
  */
 static void
 AudioTrack_ResetPositions( JNIEnv *env, audio_output_t *p_aout )
@@ -490,6 +502,50 @@ AudioTrack_ResetPositions( JNIEnv *env, audio_output_t 
*p_aout )
 p_sys-timestamp.i_last_time = 0;
 p_sys-timestamp.i_frame_us = 0;
 p_sys-timestamp.i_frame_pos = 0;
+
+p_sys-smoothpos.i_count = 0;
+p_sys-smoothpos.i_idx = 0;
+p_sys-smoothpos.i_last_time = 0;
+p_sys-smoothpos.i_us = 0;
+}
+
+/**
+ * Get a smooth AudioTrack position
+ *
+ * This function smooth out the AudioTrack position since it has a very bad
+ * precision (+/- 20ms on old devices).
+ */
+static mtime_t
+AudioTrack_GetSmoothPositionUs( JNIEnv *env, audio_output_t *p_aout )
+{
+aout_sys_t *p_sys = p_aout-sys;
+uint64_t i_audiotrack_us;
+mtime_t i_now = mdate();
+
+/* Fetch an AudioTrack position every SMOOTHPOS_INTERVAL_US (30ms) */
+if( i_now - p_sys-smoothpos.i_last_time = SMOOTHPOS_INTERVAL_US )
+{
+i_audiotrack_us = FRAMES_TO_US( AudioTrack_GetPosition( env, p_aout ) 
);
+
+p_sys-smoothpos.i_last_time = i_now;
+
+/* Base the position off the current time */
+p_sys-smoothpos.p_us[p_sys-smoothpos.i_idx] = i_audiotrack_us - 
i_now;
+p_sys-smoothpos.i_idx = (p_sys-smoothpos.i_idx + 1)
+ % SMOOTHPOS_SAMPLE_COUNT;
+if( p_sys-smoothpos.i_count  SMOOTHPOS_SAMPLE_COUNT )
+p_sys-smoothpos.i_count++;
+
+/* Calculate the average position based off the current time */
+p_sys-smoothpos.i_us = 0;
+for( uint32_t i = 0; i  p_sys-smoothpos.i_count; ++i )
+p_sys-smoothpos.i_us += p_sys-smoothpos.p_us[i];
+p_sys-smoothpos.i_us /= p_sys-smoothpos.i_count;
+}
+if( p_sys-smoothpos.i_us != 0 )
+return p_sys-smoothpos.i_us + i_now;
+else
+return 0;
 }
 
 static mtime_t
@@ -566,13 +622,8 @@ TimeGet( audio_output_t *p_aout, mtime_t *restrict p_delay 
)
 
 i_audiotrack_us = AudioTrack_GetTimestampPositionUs( env, p_aout );
 
-if( i_audiotrack_us == 0 )
-{
-uint64_t i_audiotrack_pos = AudioTrack_GetPosition( env, p_aout );
-
-if( p_sys-i_samples_written  i_audiotrack_pos )
-i_audiotrack_us = FRAMES_TO_US( i_audiotrack_pos );
-}
+if( i_audiotrack_us = 0 )
+i_audiotrack_us = AudioTrack_GetSmoothPositionUs(env, p_aout );
 
 if( i_audiotrack_us  0 )
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: add AUDIOTRACK_HW_LATENCY define

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 15 12:17:41 
2015 +0200| [a58d7c761ef81abd21a67134f661915b3519b485] | committer: Thomas 
Guillem

audiotrack: add AUDIOTRACK_HW_LATENCY define

If defined, getTimestamp (since Android 4.4) or getPlaybackHeadPosition +
getLatency (since Android 4.3) will be used to get the AudioTrack position.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a58d7c761ef81abd21a67134f661915b3519b485
---

 modules/audio_output/audiotrack.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 0e78326..450a90c 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -106,8 +106,7 @@ struct aout_sys_t {
 
 // Don't use Float for now since 5.1/7.1 Float is down sampled to Stereo Float
 //#define AUDIOTRACK_USE_FLOAT
-// TODO: activate getTimestamp for new android versions
-//#define AUDIOTRACK_USE_TIMESTAMP
+//#define AUDIOTRACK_HW_LATENCY
 
 #define AUDIO_CHAN_TEXT N_(Audio output channels)
 #define AUDIO_CHAN_LONGTEXT N_(Channels available for audio output.  \
@@ -271,8 +270,10 @@ InitJNIFields( audio_output_t *p_aout )
 } else
 GET_ID( GetMethodID, AudioTrack.write, write, ([BII)I, true );
 
+#ifdef AUDIOTRACK_HW_LATENCY
 GET_ID( GetMethodID, AudioTrack.getTimestamp,
 getTimestamp, (Landroid/media/AudioTimestamp;)Z, false );
+#endif
 GET_ID( GetMethodID, AudioTrack.getPlaybackHeadPosition,
 getPlaybackHeadPosition, ()I, true );
 
@@ -302,6 +303,7 @@ InitJNIFields( audio_output_t *p_aout )
 nanoTime, J, true );
 }
 
+#ifdef AUDIOTRACK_HW_LATENCY
 /* AudioSystem class init */
 GET_CLASS( android/media/AudioSystem, false );
 if( clazz )
@@ -310,6 +312,7 @@ InitJNIFields( audio_output_t *p_aout )
 GET_ID( GetStaticMethodID, AudioSystem.getOutputLatency,
 getOutputLatency, (I)I, false );
 }
+#endif
 
 /* AudioFormat class init */
 GET_CLASS( android/media/AudioFormat, true );
@@ -973,7 +976,6 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 }
 p_sys-i_max_audiotrack_samples = BYTES_TO_FRAMES( i_audiotrack_size );
 
-#ifdef AUDIOTRACK_USE_TIMESTAMP
 if( jfields.AudioTimestamp.clazz )
 {
 /* create AudioTimestamp object */
@@ -990,7 +992,6 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 return VLC_EGENERIC;
 }
 }
-#endif
 
 if( p_sys-fmt.i_format == VLC_CODEC_FL32 )
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: debug delays

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 15 12:17:29 
2015 +0200| [ce58d9dda1051b8fd8cbc3e5d7c439457e8802e5] | committer: Thomas 
Guillem

audiotrack: debug delays

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce58d9dda1051b8fd8cbc3e5d7c439457e8802e5
---

 modules/audio_output/audiotrack.c |   20 
 1 file changed, 20 insertions(+)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 14a6e53..0e78326 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -651,6 +651,26 @@ TimeGet( audio_output_t *p_aout, mtime_t *restrict p_delay 
)
 if( i_audiotrack_us = 0 )
 i_audiotrack_us = AudioTrack_GetSmoothPositionUs(env, p_aout );
 
+/* Debug log for both delays */
+#if 0
+{
+mtime_t i_written_us = FRAMES_TO_US( p_sys-i_samples_written );
+mtime_t i_ts_us = AudioTrack_GetTimestampPositionUs( env, p_aout );
+mtime_t i_smooth_us = 0;
+
+if( i_ts_us  0 )
+i_smooth_us = AudioTrack_GetSmoothPositionUs(env, p_aout );
+else if ( p_sys-smoothpos.i_us != 0 )
+i_smooth_us = p_sys-smoothpos.i_us + mdate()
+- p_sys-smoothpos.i_latency_us;
+
+msg_Err( p_aout, TimeGet: TimeStamp: %lld, Smooth: %lld (latency: %lld),
+i_ts_us ? i_written_us - i_ts_us : 0,
+i_smooth_us ? i_written_us - i_smooth_us : 0,
+p_sys-smoothpos.i_latency_us );
+}
+#endif
+
 if( i_audiotrack_us  0 )
 {
 mtime_t i_delay = FRAMES_TO_US( p_sys-i_samples_written )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: rename InitDelay

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 15 09:41:52 
2015 +0200| [1188440ce929e0fc077670f2873e3c475f29102f] | committer: Thomas 
Guillem

audiotrack: rename InitDelay

Since it only reset PlaybackHeadPosition.
Move i_samples_written initialisation out of this function.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1188440ce929e0fc077670f2873e3c475f29102f
---

 modules/audio_output/audiotrack.c |   18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 655e6a7..37495b6 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -438,8 +438,13 @@ AudioTrack_GetPosition( JNIEnv *env, audio_output_t 
*p_aout )
 - p_sys-headpos.i_initial;
 }
 
+/**
+ * Reset AudioTrack position
+ *
+ * Called after flush, or start
+ */
 static void
-AudioTrack_InitDelay( JNIEnv *env, audio_output_t *p_aout )
+AudioTrack_ResetPlaybackHeadPosition( JNIEnv *env, audio_output_t *p_aout )
 {
 aout_sys_t *p_sys = p_aout-sys;
 
@@ -459,7 +464,6 @@ AudioTrack_InitDelay( JNIEnv *env, audio_output_t *p_aout )
 p_sys-headpos.i_initial = JNI_AT_CALL_INT( 
getPlaybackHeadPosition );
 } while( p_sys-headpos.i_initial != i_last_pos );
 }
-p_sys-i_samples_written = 0;
 p_sys-headpos.i_last = 0;
 p_sys-headpos.i_wrap_count = 0;
 }
@@ -860,7 +864,8 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 CHECK_AT_EXCEPTION( play );
 p_sys-i_play_time = mdate();
 
-AudioTrack_InitDelay( env, p_aout );
+AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+p_sys-i_samples_written = 0;
 *p_fmt = p_sys-fmt;
 aout_SoftVolumeStart( p_aout );
 
@@ -919,7 +924,8 @@ AudioTrack_Write( JNIEnv *env, audio_output_t *p_aout, 
block_t *p_buffer,
 if( i_audiotrack_pos  p_sys-i_samples_written )
 {
 msg_Warn( p_aout, audiotrack position is ahead. Should NOT happen );
-AudioTrack_InitDelay( env, p_aout );
+AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+p_sys-i_samples_written = 0;
 return 0;
 }
 i_samples_pending = p_sys-i_samples_written - i_audiotrack_pos;
@@ -1255,7 +1261,9 @@ Flush( audio_output_t *p_aout, bool b_wait )
 (*env)-DeleteGlobalRef( env, p_sys-p_bytebuffer );
 p_sys-p_bytebuffer = NULL;
 }
-AudioTrack_InitDelay( env, p_aout );
+
+AudioTrack_ResetPlaybackHeadPosition( env, p_aout );
+p_sys-i_samples_written = 0;
 }
 
 static int

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: use uint64_t to count samples

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr 14 16:36:04 
2015 +0200| [eae5beac7d75792a2135b574125f4a323563501f] | committer: Thomas 
Guillem

audiotrack: use uint64_t to count samples

It allows to play more than 13h30min (@44.1kHz).
Add more comments for the buggy getPlaybackHeadPosition method.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eae5beac7d75792a2135b574125f4a323563501f
---

 modules/audio_output/audiotrack.c |  112 -
 1 file changed, 74 insertions(+), 38 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 2a23ca3..655e6a7 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -55,8 +55,15 @@ struct aout_sys_t {
 size_t i_floatarray_size; /* size of the FloatArray */
 jobject p_bytebuffer; /* ByteBuffer ref (for WriteV21) */
 audio_sample_format_t fmt; /* fmt setup by Start */
-uint32_t i_pos_initial; /* initial position set by getPlaybackHeadPosition 
*/
-uint32_t i_samples_written; /* number of samples written since last flush 
*/
+
+/* Used by AudioTrack_GetPosition / AudioTrack_getPlaybackHeadPosition */
+struct {
+uint64_t i_initial;
+uint32_t i_wrap_count;
+uint32_t i_last;
+} headpos;
+
+uint64_t i_samples_written; /* number of samples written since last flush 
*/
 uint32_t i_bytes_per_frame; /* byte per frame */
 uint32_t i_max_audiotrack_samples;
 mtime_t i_play_time; /* time when play was called */
@@ -361,13 +368,13 @@ check_exception( JNIEnv *env, audio_output_t *p_aout,
 #define JNI_AUDIOTIMESTAMP_GET_LONG( field ) JNI_CALL( GetLongField, 
p_sys-p_audioTimestamp, jfields.AudioTimestamp.field )
 
 static inline mtime_t
-frames_to_us( aout_sys_t *p_sys, uint32_t i_nb_frames )
+frames_to_us( aout_sys_t *p_sys, uint64_t i_nb_frames )
 {
 return  i_nb_frames * CLOCK_FREQ / p_sys-fmt.i_rate;
 }
 #define FRAMES_TO_US(x) frames_to_us( p_sys, (x) )
 
-static inline uint32_t
+static inline uint64_t
 bytes_to_frames( aout_sys_t *p_sys, size_t i_bytes )
 {
 if( p_sys-b_spdif )
@@ -378,7 +385,7 @@ bytes_to_frames( aout_sys_t *p_sys, size_t i_bytes )
 #define BYTES_TO_FRAMES(x) bytes_to_frames( p_sys, (x) )
 
 static inline size_t
-frames_to_bytes( aout_sys_t *p_sys, uint32_t i_frames )
+frames_to_bytes( aout_sys_t *p_sys, uint64_t i_frames )
 {
 if( p_sys-b_spdif )
 return i_frames * p_sys-i_bytes_per_frame / A52_FRAME_NB;
@@ -387,46 +394,74 @@ frames_to_bytes( aout_sys_t *p_sys, uint32_t i_frames )
 }
 #define FRAMES_TO_BYTES(x) frames_to_bytes( p_sys, (x) )
 
+/**
+ * Get the AudioTrack position
+ *
+ * The doc says that the position is reset to zero after flush but it's not
+ * true for all devices or Android versions. Use AudioTrack_GetPosition 
instead.
+ */
+static uint64_t
+AudioTrack_getPlaybackHeadPosition( JNIEnv *env, audio_output_t *p_aout )
+{
+/* Android doc:
+ * getPlaybackHeadPosition: Returns the playback head position expressed in
+ * frames. Though the int type is signed 32-bits, the value should be
+ * reinterpreted as if it is unsigned 32-bits. That is, the next position
+ * after 0x7FFF is (int) 0x8000. This is a continuously advancing
+ * counter. It will wrap (overflow) periodically, for example approximately
+ * once every 27:03:11 hours:minutes:seconds at 44.1 kHz. It is reset to
+ * zero by flush(), reload(), and stop().
+ */
+
+aout_sys_t *p_sys = p_aout-sys;
+uint32_t i_pos;
+
+/* int32_t to uint32_t */
+i_pos = 0xL  JNI_AT_CALL_INT( getPlaybackHeadPosition );
+
+/* uint32_t to uint64_t */
+if( p_sys-headpos.i_last  i_pos )
+p_sys-headpos.i_wrap_count++;
+p_sys-headpos.i_last = i_pos;
+return p_sys-headpos.i_last + ((uint64_t)p_sys-headpos.i_wrap_count  
32);
+}
+
+/**
+ * Get the AudioTrack position since the last flush or stop
+ */
+static uint64_t
+AudioTrack_GetPosition( JNIEnv *env, audio_output_t *p_aout )
+{
+aout_sys_t *p_sys = p_aout-sys;
+
+return AudioTrack_getPlaybackHeadPosition( env, p_aout )
+- p_sys-headpos.i_initial;
+}
+
 static void
 AudioTrack_InitDelay( JNIEnv *env, audio_output_t *p_aout )
 {
 aout_sys_t *p_sys = p_aout-sys;
 
 if( p_sys-p_audiotrack )
-p_sys-i_pos_initial = JNI_AT_CALL_INT( getPlaybackHeadPosition );
+p_sys-headpos.i_initial = AudioTrack_getPlaybackHeadPosition( env, 
p_aout );
 else
-p_sys-i_pos_initial = 0;
+p_sys-headpos.i_initial = 0;
 
 /* HACK: On some broken devices, head position is still moving after a
  * flush or a stop. So, wait for the head position to be stabilized. */
-if( unlikely( p_sys-i_pos_initial != 0 ) )
+if( unlikely( p_sys-headpos.i_initial != 0 ) )
 {
-uint32_t i_last_pos;
+uint64_t i_last_pos;
 do {
-i_last_pos = p_sys-i_pos_initial

[vlc-commits] audiotrack: fix AudioTimestamp

2015-04-15 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr 15 10:27:46 
2015 +0200| [0bd6c08be1a7ddc8060be1989310cb2b81d4925d] | committer: Thomas 
Guillem

audiotrack: fix AudioTimestamp

Move AudioTimestamp variables into a separate struct.
Move AudioTimestamp calculation into a separate function.
Call getTimestamp every 500ms, keep the previous result in cache.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0bd6c08be1a7ddc8060be1989310cb2b81d4925d
---

 modules/audio_output/audiotrack.c |  181 -
 1 file changed, 116 insertions(+), 65 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=0bd6c08be1a7ddc8060be1989310cb2b81d4925d
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: improve performances

2015-04-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 13 11:40:02 
2015 +0200| [0953e658252e393436ee17b3f5f25246a353f09f] | committer: Thomas 
Guillem

mediacodec: improve performances

Don't abort DecodeVideo when there is no p_block. It allows to fetch more than
one output buffer consequently.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0953e658252e393436ee17b3f5f25246a353f09f
---

 modules/codec/omxil/android_mediacodec.c |   24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 976ebfe..5d78953 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -1024,9 +1024,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 decoder_sys_t *p_sys = p_dec-p_sys;
 picture_t *p_pic = NULL;
 JNIEnv *env = NULL;
-
-if (!pp_block || !*pp_block)
-return NULL;
+block_t *p_block = pp_block ? *pp_block : NULL;
 
 if (p_sys-error_state)
 goto endclean;
@@ -1034,8 +1032,8 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 if (!(env = jni_get_env(THREAD_NAME)))
 goto endclean;
 
-if ((*pp_block)-i_flags  
(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) {
-block_Release(*pp_block);
+if (p_block  p_block-i_flags  
(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED)) {
+block_Release(p_block);
 *pp_block = NULL;
 p_sys-i_preroll_end = 0;
 timestamp_FifoEmpty(p_sys-timestamp_fifo);
@@ -1068,12 +1066,11 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 jlong timeout = 0;
 int i_output_ret = 0;
 int i_input_ret = 0;
-/* return when pp_block is processed or when we got an output pic */
-while (i_input_ret != 1  i_output_ret != 1) {
-if (i_input_ret == 0) {
-i_input_ret = PutInput(p_dec, env, *pp_block, timeout);
+do {
+if (p_block  i_input_ret == 0) {
+i_input_ret = PutInput(p_dec, env, p_block, timeout);
 if (i_input_ret == 1) {
-block_Release(*pp_block);
+block_Release(p_block);
 *pp_block = NULL;
 } else if (i_input_ret == -1) {
 p_sys-error_state = true;
@@ -1117,13 +1114,14 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 }
 }
 timeout = 10 * 1000; // 10 ms
-}
+/* loop until input is processed or when we got an output pic */
+} while (p_block  i_input_ret != 1  i_output_ret != 1);
 
 endclean:
 if (p_sys-error_state) {
-if( pp_block  *pp_block )
+if( p_block )
 {
-block_Release(*pp_block);
+block_Release(p_block);
 *pp_block = NULL;
 }
 if (p_pic)

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] libvlc: remove duplicate line

2015-04-13 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Apr 13 15:29:10 
2015 +0200| [dd9aa4361846b32b2af5b1d39b2898f83b84f0d9] | committer: Thomas 
Guillem

libvlc: remove duplicate line

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dd9aa4361846b32b2af5b1d39b2898f83b84f0d9
---

 lib/event.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/event.c b/lib/event.c
index 2ed7c5b..4a95cee 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -80,7 +80,6 @@ libvlc_event_manager_new( void * p_obj, libvlc_instance_t * 
p_libvlc_inst )
 }
 
 p_em-p_obj = p_obj;
-p_em-p_obj = p_obj;
 p_em-async_event_queue = NULL;
 p_em-p_libvlc_instance = p_libvlc_inst;
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] dvdnav: add Demux submodule

2015-04-12 Thread Thomas Guillem
vlc/vlc-2.2 | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr 10 
12:20:17 2015 +0200| [059d996e51b8531bbaaedecc3a4db28813f2ed48] | committer: 
Jean-Baptiste Kempf

dvdnav: add Demux submodule

It allows to use dvdnav via a VLC access using new dvdnav stream callbacks.

When using a VLC access, dvdnav readahead flag is disabled in order to read
small chunk of data from pf_demux (that is 2kB).

This is disabled by default and must be forced

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=059d996e51b8531bbaaedecc3a4db28813f2ed48
---

 modules/access/dvdnav.c |  261 ++-
 1 file changed, 191 insertions(+), 70 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commitdiff;h=059d996e51b8531bbaaedecc3a4db28813f2ed48
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] PulseAudio: fix audio drop after a flush

2015-04-18 Thread Thomas Guillem
vlc/vlc-2.2 | branch: master | Thomas Guillem tho...@gllm.fr | Sat Apr 18 
01:18:35 2015 +0200| [20be876d7c1b39b4a8072ff913d9bdf95300d2e4] | committer: 
Rémi Denis-Courmont

PulseAudio: fix audio drop after a flush

It happens when pa_stream_write is called too late after a flush.
This fixes audio drop when the track has a positive delay.

Signed-off-by: Rémi Denis-Courmont r...@remlab.net
(cherry picked from commit 7de1c701a5a43fd5a5cbd236fa64d750a356c7de)

 http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=20be876d7c1b39b4a8072ff913d9bdf95300d2e4
---

 modules/audio_output/pulse.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 069cf6a..231769d 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -561,6 +561,9 @@ static void Flush(audio_output_t *aout, bool wait)
 op = pa_stream_flush(s, NULL, NULL);
 if (op != NULL)
 pa_operation_unref(op);
+sys-first_pts = VLC_TS_INVALID;
+stream_stop(s, aout);
+
 pa_threaded_mainloop_unlock(sys-mainloop);
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: use device native sample rate

2015-04-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr  7 11:40:12 
2015 +0200| [82657449a952e06a372c39929e5af3fedbac91ee] | committer: 
Jean-Baptiste Kempf

audiotrack: use device native sample rate

VLC resampler  android resampler

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=82657449a952e06a372c39929e5af3fedbac91ee
---

 modules/audio_output/audiotrack.c |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 06842bd..bb79d46 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -111,6 +111,7 @@ static struct
 jmethodID getPlaybackHeadPosition;
 jmethodID getTimestamp;
 jmethodID getMinBufferSize;
+jmethodID getNativeOutputSampleRate;
 jint STATE_INITIALIZED;
 jint MODE_STREAM;
 jint ERROR;
@@ -237,6 +238,8 @@ InitJNIFields( audio_output_t *p_aout )
 
 GET_ID( GetStaticMethodID, AudioTrack.getMinBufferSize, getMinBufferSize,
 (III)I, true );
+GET_ID( GetStaticMethodID, AudioTrack.getNativeOutputSampleRate,
+getNativeOutputSampleRate,  (I)I, true );
 GET_CONST_INT( AudioTrack.STATE_INITIALIZED, STATE_INITIALIZED, true );
 GET_CONST_INT( AudioTrack.MODE_STREAM, MODE_STREAM, true );
 GET_CONST_INT( AudioTrack.ERROR, ERROR, true );
@@ -628,7 +631,9 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 aout_sys_t *p_sys = p_aout-sys;
 JNIEnv *env;
 jobject p_audiotrack = NULL;
-int i_nb_channels, i_audiotrack_size, i_bytes_per_frame;
+int i_nb_channels, i_audiotrack_size, i_bytes_per_frame,
+i_native_rate;
+unsigned int i_rate;
 
 if( !( env = jni_get_env( THREAD_NAME ) ) )
 return VLC_EGENERIC;
@@ -639,8 +644,13 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 
 p_sys-fmt.i_original_channels = p_sys-fmt.i_physical_channels;
 
-/* 4000 = frequency = 48000 */
-p_sys-fmt.i_rate = VLC_CLIP( p_sys-fmt.i_rate, 4000, 48000 );
+i_native_rate = JNI_AT_CALL_STATIC_INT( getNativeOutputSampleRate,
+jfields.AudioManager.STREAM_MUSIC 
);
+if( i_native_rate = 0 )
+{
+msg_Warn( p_aout, negative native rate ? Should not happen ! );
+i_native_rate = VLC_CLIP( p_sys-fmt.i_rate, 4000, 48000 );
+}
 
 /* We can only accept U8, S16N, FL32, and AC3 */
 switch( p_sys-fmt.i_format )
@@ -690,12 +700,15 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 {
 i_bytes_per_frame = i_nb_channels *
 aout_BitsPerSample( p_sys-fmt.i_format ) / 8;
+i_rate = p_sys-fmt.i_format == VLC_CODEC_SPDIFB ?
+VLC_CLIP( p_sys-fmt.i_rate, 32000, 
48000 )
+: (unsigned int) i_native_rate;
 
 /* Try to create an AudioTrack with the most advanced channel and
  * format configuration. If AudioTrack_New fails, try again with a less
  * advanced format (PCM S16N). If it fails again, try again with Stereo
  * channels. */
-p_audiotrack = AudioTrack_New( env, p_aout, p_sys-fmt.i_rate,
+p_audiotrack = AudioTrack_New( env, p_aout, i_rate,
p_sys-fmt.i_format,
p_sys-fmt.i_physical_channels,
i_bytes_per_frame,
@@ -737,6 +750,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 if( !p_sys-p_audiotrack )
 return VLC_EGENERIC;
 
+p_sys-fmt.i_rate = i_rate;
 p_sys-b_spdif = p_sys-fmt.i_format == VLC_CODEC_SPDIFB;
 if( p_sys-b_spdif )
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] modules: remove bashism

2015-04-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr  7 09:15:48 
2015 +0200| [21af43fa2853ddd90ef1c8b2e4945d4daf1224e4] | committer: 
Jean-Baptiste Kempf

modules: remove bashism

It Fixes OS/2 compilation.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=21af43fa2853ddd90ef1c8b2e4945d4daf1224e4
---

 modules/common.am |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/common.am b/modules/common.am
index 9ac2929..65c962a 100644
--- a/modules/common.am
+++ b/modules/common.am
@@ -15,7 +15,7 @@ CLEANFILES = $(BUILT_SOURCES)
 LTLIBVLCCORE = $(top_builddir)/src/libvlccore.la
 
 # Module name from object or executable file name.
-MODULE_NAME = $$(p=$@; p=$${p\#\#*/}; p=$${p\#lib}; p=$${p%_plugin*}; 
p=$${p//-/\_}; p=$${p%.lo}; echo $$p)
+MODULE_NAME = $$(p=$@; p=$${p\#\#*/}; p=$${p\#lib}; p=$${p%_plugin*}; 
p=$$(echo $$p|sed 's/-/_/g'); p=$${p%.lo}; echo $$p)
 
 AM_CPPFLAGS = -DMODULE_STRING=\$(MODULE_NAME)\
 if HAVE_DYNAMIC_PLUGINS

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec/omxil: use same blacklist

2015-04-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 14:17:40 
2015 +| [604ef756395a884036fd81a41ae098261fc55df4] | committer: 
Jean-Baptiste Kempf

mediacodec/omxil: use same blacklist

A crashing decoder via MediaCodec has a lot of chances to crash via omxil.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=604ef756395a884036fd81a41ae098261fc55df4
---

 modules/codec/omxil/android_mediacodec.c |   24 +--
 modules/codec/omxil/omxil.c  |   35 +---
 modules/codec/omxil/omxil_utils.h|5 +++
 modules/codec/omxil/utils.c  |   66 ++
 4 files changed, 73 insertions(+), 57 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index adf88e2..94c0113 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -390,28 +390,6 @@ end:
 return ret;
 }
 
-static bool codec_is_blacklisted( const char *p_name, unsigned int i_name_len )
-{
- static const char *blacklisted_codecs[] = {
-/* software decoders */
-OMX.google.,
-/* crashes mediaserver */
-OMX.MTK.VIDEO.DECODER.MPEG4,
-/* Not working or crashing (Samsung) */
-OMX.SEC.vp8.dec,
-NULL,
- };
-
- for( const char **pp_bl_codecs = blacklisted_codecs; *pp_bl_codecs != 
NULL;
-  pp_bl_codecs++ )
- {
-if( !strncmp( p_name, *pp_bl_codecs,
-__MIN( strlen(*pp_bl_codecs), i_name_len ) ) )
-return true;
- }
- return false;
-}
-
 /*
  * OpenDecoder: Create the decoder instance
  */
@@ -499,7 +477,7 @@ static int OpenDecoder(vlc_object_t *p_this)
 name_ptr = (*env)-GetStringUTFChars(env, name, NULL);
 found = false;
 
-if (codec_is_blacklisted( name_ptr, name_len))
+if (OMXCodec_IsBlacklisted( name_ptr, name_len))
 goto loopclean;
 for (int j = 0; j  num_types  !found; j++) {
 jobject type = (*env)-GetObjectArrayElement(env, types, j);
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 16eb50e..1f6ebf4 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1109,40 +1109,7 @@ static int OpenGeneric( vlc_object_t *p_this, bool 
b_encode )
 for(i = 0; i  p_sys-components; i++)
 {
 #ifdef __ANDROID__
-/* ignore OpenCore software codecs */
-if (!strncmp(p_sys-ppsz_components[i], OMX.PV., 7))
-continue;
-/* The same sw codecs, renamed in ICS (perhaps also in honeycomb) */
-if (!strncmp(p_sys-ppsz_components[i], OMX.google., 11))
-continue;
-/* This one has been seen on HTC One V - it behaves like it works,
- * but FillBufferDone returns buffers filled with 0 bytes. The One V
- * has got a working OMX.qcom.video.decoder.avc instead though. */
-if (!strncmp(p_sys-ppsz_components[i], OMX.ARICENT., 12))
-continue;
-/* Codecs with DRM, that don't output plain YUV data but only
- * support direct rendering where the output can't be intercepted. */
-if (strstr(p_sys-ppsz_components[i], .secure))
-continue;
-/* Use VC1 decoder for WMV3 for now */
-if (!strcmp(p_sys-ppsz_components[i], OMX.SEC.WMV.Decoder))
-continue;
-/* This decoder does work, but has an insane latency (leading to errors
- * about main audio output playback way too late and dropped frames).
- * At least Samsung Galaxy S III (where this decoder is present) has
- * got another one, OMX.SEC.mp3.dec, that works well and has a
- * sensible latency. (Also, even if that one isn't found, in general,
- * using SW codecs is usually more than fast enough for MP3.) */
-if (!strcmp(p_sys-ppsz_components[i], OMX.SEC.MP3.Decoder))
-continue;
-/* This codec should be able to handle both VC1 and WMV3, but
- * for VC1 it doesn't output any buffers at all (in the way we use
- * it) and for WMV3 it outputs plain black buffers. Thus ignore
- * it until we can make it work properly. */
-if (!strcmp(p_sys-ppsz_components[i], OMX.Nvidia.vc1.decode))
-continue;
-/* This codec doesn't work or crashes */
-if (!strcmp(p_sys-ppsz_components[i], OMX.SEC.vp8.dec))
+if (OMXCodec_IsBlacklisted(p_sys-ppsz_components[i], 
strlen(p_sys-ppsz_components[i])))
 continue;
 #endif
 omx_error = InitialiseComponent(p_dec, p_sys-ppsz_components[i],
diff --git a/modules/codec/omxil/omxil_utils.h 
b/modules/codec/omxil/omxil_utils.h
index a1d564b..04a56bd 100644
--- a/modules/codec/omxil

[vlc-commits] mediacodec/omxil: blacklist samsung sw decoders

2015-04-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Fri Apr  3 14:17:41 
2015 +| [b1e890189b1ce3ca5cc0dddfed3359afb14171cc] | committer: 
Jean-Baptiste Kempf

mediacodec/omxil: blacklist samsung sw decoders

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b1e890189b1ce3ca5cc0dddfed3359afb14171cc
---

 modules/codec/omxil/utils.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/codec/omxil/utils.c b/modules/codec/omxil/utils.c
index 6ec82cc..31a491d 100644
--- a/modules/codec/omxil/utils.c
+++ b/modules/codec/omxil/utils.c
@@ -345,6 +345,8 @@ bool OMXCodec_IsBlacklisted( const char *p_name, unsigned 
int i_name_len )
 /* Codecs with DRM, that don't output plain YUV data but only
  * support direct rendering where the output can't be intercepted. */
 .secure,
+/* Samsung sw decoders */
+.sw.dec,
 NULL
 };
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: add an option for maximum number of channels

2015-04-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Apr  7 19:24:21 
2015 +0200| [5816897e9fe277e3842e71702bd2c7c30a8b6715] | committer: 
Jean-Baptiste Kempf

audiotrack: add an option for maximum number of channels

Android mediaserver crashes when you output 5.1 PCM @48kHz via Audiotrack with
a lot of QCOM devices due to a SIGSEGV in their resampler. It happens with
Samsung Galaxy Tab 3/4, Galaxy S4/S5 and many other devices.

Therefore, activate surround only via an extra option.

Signed-off-by: Jean-Baptiste Kempf j...@videolan.org

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5816897e9fe277e3842e71702bd2c7c30a8b6715
---

 modules/audio_output/audiotrack.c |   18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index bb79d46..2a23ca3 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -80,6 +80,11 @@ struct aout_sys_t {
 // TODO: activate getTimestamp for new android versions
 //#define AUDIOTRACK_USE_TIMESTAMP
 
+#define AUDIO_CHAN_TEXT N_(Audio output channels)
+#define AUDIO_CHAN_LONGTEXT N_(Channels available for audio output.  \
+If the input has more channels than the output, it will be down-mixed.  \
+This parameter is ignored when digital pass-through is active.)
+
 vlc_module_begin ()
 set_shortname( AudioTrack )
 set_description( N_( Android AudioTrack audio output ) )
@@ -88,6 +93,8 @@ vlc_module_begin ()
 set_subcategory( SUBCAT_AUDIO_AOUT )
 add_sw_gain()
 add_shortcut( audiotrack )
+add_integer( audiotrack-audio-channels, 2,
+ AUDIO_CHAN_TEXT, AUDIO_CHAN_LONGTEXT, true)
 set_callbacks( Open, Close )
 vlc_module_end ()
 
@@ -631,9 +638,13 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 aout_sys_t *p_sys = p_aout-sys;
 JNIEnv *env;
 jobject p_audiotrack = NULL;
-int i_nb_channels, i_audiotrack_size, i_bytes_per_frame,
+int i_nb_channels, i_max_channels, i_audiotrack_size, i_bytes_per_frame,
 i_native_rate;
 unsigned int i_rate;
+bool b_spdif;
+
+b_spdif = var_InheritBool( p_aout, spdif );
+i_max_channels = var_InheritInteger( p_aout, audiotrack-audio-channels );
 
 if( !( env = jni_get_env( THREAD_NAME ) ) )
 return VLC_EGENERIC;
@@ -664,8 +675,7 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
 p_sys-fmt.i_format = VLC_CODEC_S16N;
 break;
 case VLC_CODEC_A52:
-if( jfields.AudioFormat.has_ENCODING_AC3
- var_InheritBool( p_aout, spdif ) )
+if( jfields.AudioFormat.has_ENCODING_AC3  b_spdif )
 p_sys-fmt.i_format = VLC_CODEC_SPDIFB;
 else if( jfields.AudioFormat.has_ENCODING_PCM_FLOAT )
 p_sys-fmt.i_format = VLC_CODEC_FL32;
@@ -681,6 +691,8 @@ Start( audio_output_t *p_aout, audio_sample_format_t 
*restrict p_fmt )
  * Android will downmix to stereo if audio output doesn't handle 5.1 or 7.1
  */
 i_nb_channels = aout_FormatNbChannels( p_sys-fmt );
+if( p_sys-fmt.i_format != VLC_CODEC_SPDIFB )
+i_nb_channels = __MIN( i_max_channels, i_nb_channels );
 if( i_nb_channels  5 )
 {
 if( i_nb_channels  7  jfields.AudioFormat.has_CHANNEL_OUT_SIDE )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] dvdnav: Fix demux returning success in case or error

2015-04-09 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr  9 12:55:56 
2015 +0200| [d59b81a897c36b7d6227c5892d63b90d8febd786] | committer: Thomas 
Guillem

dvdnav: Fix demux returning success in case or error

It happened when StreamProbeDVD succeeded and when dvdnav_open_stream failed.

Fixes #14300

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d59b81a897c36b7d6227c5892d63b90d8febd786
---

 modules/access/dvdnav.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 43fed80..236b970 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -445,7 +445,7 @@ static int DemuxOpen ( vlc_object_t *p_this )
 {
 demux_t *p_demux = (demux_t*)p_this;
 dvdnav_t *p_dvdnav = NULL;
-int i_ret;
+int i_ret = VLC_EGENERIC;
 int64_t i_init_pos;
 bool forced = false, b_seekable = false;
 
@@ -463,7 +463,7 @@ static int DemuxOpen ( vlc_object_t *p_this )
 i_init_pos = stream_Tell( p_demux-s );
 
 /* Try some simple probing to avoid going through dvdnav_open too often */
-if( !forced  (i_ret = StreamProbeDVD( p_demux-s )) != VLC_SUCCESS )
+if( !forced  StreamProbeDVD( p_demux-s ) != VLC_SUCCESS )
 goto bailout;
 
 static dvdnav_stream_cb stream_cb =

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] android: remove jni_IsVideoPlayerActivityCreated

2015-04-09 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr  8 17:17:51 
2015 +0200| [027663d02d2bd7e917b3f10001f99a7de09d1dbd] | committer: Thomas 
Guillem

android: remove jni_IsVideoPlayerActivityCreated

VideoPlayer is now started when surfaces are available.

If no surfaces are available, don't wait for it, and return an error (and
fallback to audio only).

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=027663d02d2bd7e917b3f10001f99a7de09d1dbd
---

 modules/codec/omxil/android_mediacodec.c  |6 +-
 modules/codec/omxil/omxil.c   |3 +--
 modules/video_output/android/android_window.c |8 
 3 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 3fb5680..976ebfe 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -55,7 +55,6 @@ extern JNIEnv *jni_get_env(const char *name);
 extern jobject jni_LockAndGetAndroidJavaSurface();
 extern void jni_UnlockAndroidSurface();
 extern void jni_EventHardwareAccelerationError();
-extern bool jni_IsVideoPlayerActivityCreated();
 
 /* Implementation of a circular buffer of timestamps with overwriting
  * of older values. MediaCodec has only one type of timestamp, if a
@@ -581,10 +580,7 @@ loopclean:
 (*env)-DeleteLocalRef(env, bytebuf);
 }
 
-/* If the VideoPlayerActivity is not started, MediaCodec opaque
-   direct rendering should be disabled since no surface will be
-   attached to the JNI. */
-p_sys-direct_rendering = jni_IsVideoPlayerActivityCreated()  
var_InheritBool(p_dec, CFG_PREFIX dr);
+p_sys-direct_rendering = var_InheritBool(p_dec, CFG_PREFIX dr);
 
 /* There is no way to rotate the video using direct rendering (and using a
  * SurfaceView) before  API 21 (Lollipop). Therefore, we deactivate direct
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index fd1d6f0..0176707 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -71,7 +71,6 @@
 extern JNIEnv *jni_get_env(const char *name);
 extern jobject jni_LockAndGetAndroidJavaSurface();
 extern void jni_UnlockAndroidSurface();
-extern bool jni_IsVideoPlayerActivityCreated();
 #endif
 
 /*
@@ -1077,7 +1076,7 @@ static int OpenGeneric( vlc_object_t *p_this, bool 
b_encode )
 p_sys-in.p_fmt = p_dec-fmt_in;
 OMX_FIFO_INIT (p_sys-out.fifo, pInputPortPrivate );
 #if defined(USE_IOMX)
-p_sys-out.b_direct = jni_IsVideoPlayerActivityCreated()  
var_InheritBool(p_dec, CFG_PREFIX dr);
+p_sys-out.b_direct = var_InheritBool(p_dec, CFG_PREFIX dr);
 #else
 p_sys-out.b_direct = false;
 #endif
diff --git a/modules/video_output/android/android_window.c 
b/modules/video_output/android/android_window.c
index b7719b1..f17bb0d 100644
--- a/modules/video_output/android/android_window.c
+++ b/modules/video_output/android/android_window.c
@@ -72,7 +72,6 @@ extern jobject jni_LockAndGetAndroidJavaSurface();
 extern jobject jni_LockAndGetSubtitlesSurface();
 extern void  jni_UnlockAndroidSurface();
 
-extern bool jni_IsVideoPlayerActivityCreated();
 extern void  jni_SetSurfaceLayout(int width, int height, int visible_width, 
int visible_height, int sar_num, int sar_den);
 extern int jni_ConfigureSurface(jobject jsurf, int width, int height, int hal, 
bool *configured);
 extern int jni_GetWindowSize(int *width, int *height);
@@ -638,13 +637,6 @@ static int Open(vlc_object_t *p_this)
 if (vout_display_IsWindowed(vd))
 return VLC_EGENERIC;
 
-/* XXX: android_window use a surface created by VideoPlayerActivity to
- * alloc pictures. Don't try to open the vout if this activity is not
- * created. This need to be replaced by something like var_CreateGetAddress
- * (vd, drawable-android) in the future. */
-if (!jni_IsVideoPlayerActivityCreated())
-return VLC_EGENERIC;
-
 /* Allocate structure */
 vd-sys = sys = (struct vout_display_sys_t*)calloc(1, sizeof(*sys));
 if (!sys)

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] android: update with last jni_LockAndGetAndroidJavaSurface changes

2015-04-09 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr  8 17:16:05 
2015 +0200| [6ce78b99b69ed221d80c494723719db1b2b55006] | committer: Thomas 
Guillem

android: update with last jni_LockAndGetAndroidJavaSurface changes

if jni_LockAndGetAndroidJavaSurface returns NULL, no need to unlock.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ce78b99b69ed221d80c494723719db1b2b55006
---

 modules/codec/omxil/android_mediacodec.c  |2 +-
 modules/codec/omxil/omxil.c   |1 -
 modules/video_output/android/android_window.c |4 
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 73e0b4f..3fb5680 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -628,11 +628,11 @@ loopclean:
 goto error;
 }
 p_dec-fmt_out.i_codec = VLC_CODEC_ANDROID_OPAQUE;
+jni_UnlockAndroidSurface();
 } else {
 msg_Warn(p_dec, Failed to get the Android Surface, disabling 
direct rendering.);
 p_sys-direct_rendering = false;
 }
-jni_UnlockAndroidSurface();
 }
 if (!p_sys-direct_rendering) {
 (*env)-CallVoidMethod(env, p_sys-codec, jfields.configure, format, 
NULL, NULL, 0);
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 1f6ebf4..fd1d6f0 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -2060,7 +2060,6 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort 
*p_port )
 
 surf = jni_LockAndGetAndroidJavaSurface();
 if( !surf ) {
-jni_UnlockAndroidSurface();
 msg_Warn( p_dec, jni_LockAndGetAndroidJavaSurface failed );
 goto error;
 }
diff --git a/modules/video_output/android/android_window.c 
b/modules/video_output/android/android_window.c
index 5d183c0..b7719b1 100644
--- a/modules/video_output/android/android_window.c
+++ b/modules/video_output/android/android_window.c
@@ -578,6 +578,8 @@ static int SetupWindowSurface(vout_display_sys_t *sys, 
unsigned i_pic_count)
 {
 int err;
 jobject jsurf = jni_LockAndGetAndroidJavaSurface();
+if (!jsurf)
+return -1;
 err = AndroidWindow_SetSurface(sys, sys-p_window, jsurf);
 jni_UnlockAndroidSurface();
 err = err == 0 ? AndroidWindow_Setup(sys, sys-p_window, i_pic_count) : 
err;
@@ -588,6 +590,8 @@ static int SetupWindowSubtitleSurface(vout_display_sys_t 
*sys)
 {
 int err;
 jobject jsurf = jni_LockAndGetSubtitlesSurface();
+if (!jsurf)
+return -1;
 err = AndroidWindow_SetSurface(sys, sys-p_sub_window, jsurf);
 jni_UnlockAndroidSurface();
 err = err == 0 ? AndroidWindow_Setup(sys, sys-p_sub_window, 1) : err;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] android_window: refactor and move functions

2015-04-09 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Apr  8 17:12:47 
2015 +0200| [0b83473c64d328779e4db272973c058766cdbd71] | committer: Thomas 
Guillem

android_window: refactor and move functions

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b83473c64d328779e4db272973c058766cdbd71
---

 modules/video_output/android/android_window.c |   53 +
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/modules/video_output/android/android_window.c 
b/modules/video_output/android/android_window.c
index 6d4f16a..5d183c0 100644
--- a/modules/video_output/android/android_window.c
+++ b/modules/video_output/android/android_window.c
@@ -327,43 +327,24 @@ static android_window 
*AndroidWindow_New(vout_display_sys_t *sys,
 return p_window;
 }
 
-static void AndroidWindow_Destroy(vout_display_sys_t *sys,
-  android_window *p_window)
-{
-if (p_window-p_handle_priv)
-sys-anwp.disconnect(p_window-p_handle_priv);
-if (p_window-p_handle)
-sys-anw.winRelease(p_window-p_handle);
-free(p_window);
-}
-
-static int AndroidWindow_UpdateCrop(vout_display_sys_t *sys,
-android_window *p_window)
-{
-if (!p_window-p_handle_priv)
-return -1;
-
-return sys-anwp.setCrop(p_window-p_handle_priv,
- p_window-fmt.i_x_offset,
- p_window-fmt.i_y_offset,
- p_window-fmt.i_visible_width,
- p_window-fmt.i_visible_height);
-}
-
 static int AndroidWindow_SetSurface(vout_display_sys_t *sys,
 android_window *p_window,
 jobject jsurf)
 {
-if (p_window-p_handle  jsurf != p_window-jsurf) {
+if (jsurf != p_window-jsurf) {
 if (p_window-p_handle_priv) {
 sys-anwp.disconnect(p_window-p_handle_priv);
 p_window-p_handle_priv = NULL;
 }
-sys-anw.winRelease(p_window-p_handle);
-p_window-p_handle = NULL;
+if (p_window-p_handle) {
+sys-anw.winRelease(p_window-p_handle);
+p_window-p_handle = NULL;
+}
 }
 
 p_window-jsurf = jsurf;
+if (!p_window-jsurf )
+return -1;
 if (!p_window-p_handle  !p_window-b_opaque) {
 JNIEnv *p_env;
 
@@ -377,6 +358,26 @@ static int AndroidWindow_SetSurface(vout_display_sys_t 
*sys,
 return 0;
 }
 
+static void AndroidWindow_Destroy(vout_display_sys_t *sys,
+  android_window *p_window)
+{
+AndroidWindow_SetSurface(sys, p_window, NULL);
+free(p_window);
+}
+
+static int AndroidWindow_UpdateCrop(vout_display_sys_t *sys,
+android_window *p_window)
+{
+if (!p_window-p_handle_priv)
+return -1;
+
+return sys-anwp.setCrop(p_window-p_handle_priv,
+ p_window-fmt.i_x_offset,
+ p_window-fmt.i_y_offset,
+ p_window-fmt.i_visible_width,
+ p_window-fmt.i_visible_height);
+}
+
 static int AndroidWindow_SetupANWP(vout_display_sys_t *sys,
android_window *p_window,
bool b_java_configured)

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: check if codec is blacklisted first

2015-04-09 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Apr  9 10:52:00 
2015 +0200| [2ac314626f2afca4cdb302fb223fe4291366e0df] | committer: Thomas 
Guillem

mediacodec: check if codec is blacklisted first

Because getCapabilitiesForType can crash.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2ac314626f2afca4cdb302fb223fe4291366e0df
---

 modules/codec/omxil/android_mediacodec.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/codec/omxil/android_mediacodec.c 
b/modules/codec/omxil/android_mediacodec.c
index 94c0113..73e0b4f 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -455,6 +455,14 @@ static int OpenDecoder(vlc_object_t *p_this)
 
 info = (*env)-CallStaticObjectMethod(env, 
jfields.media_codec_list_class,
   jfields.get_codec_info_at, i);
+
+name = (*env)-CallObjectMethod(env, info, jfields.get_name);
+name_len = (*env)-GetStringUTFLength(env, name);
+name_ptr = (*env)-GetStringUTFChars(env, name, NULL);
+
+if (OMXCodec_IsBlacklisted( name_ptr, name_len))
+goto loopclean;
+
 if ((*env)-CallBooleanMethod(env, info, jfields.is_encoder))
 goto loopclean;
 
@@ -472,13 +480,8 @@ static int OpenDecoder(vlc_object_t *p_this)
 
 types = (*env)-CallObjectMethod(env, info, 
jfields.get_supported_types);
 num_types = (*env)-GetArrayLength(env, types);
-name = (*env)-CallObjectMethod(env, info, jfields.get_name);
-name_len = (*env)-GetStringUTFLength(env, name);
-name_ptr = (*env)-GetStringUTFChars(env, name, NULL);
 found = false;
 
-if (OMXCodec_IsBlacklisted( name_ptr, name_len))
-goto loopclean;
 for (int j = 0; j  num_types  !found; j++) {
 jobject type = (*env)-GetObjectArrayElement(env, types, j);
 if (!jstrcmp(env, type, mime)) {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: Open/Close: separate JNI part from Decoder part

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon May 18 18:25:35 
2015 +0200| [d6d6f3013c61e2d96d33d4cac7235785585d] | committer: Thomas 
Guillem

mediacodec: Open/Close: separate JNI part from Decoder part

Rename OpenMediaCodec to StartMediaCodec and CloseMediaCodec to StopMediaCodec.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d6d6f3013c61e2d96d33d4cac7235785585d
---

 modules/codec/omxil/mediacodec.c |  334 --
 1 file changed, 173 insertions(+), 161 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=d6d6f3013c61e2d96d33d4cac7235785585d
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: add NDK module

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed May 20 14:33:33 
2015 +0200| [286fa11d5024d6b35063adb950c8f1b9f7d6a9e9] | committer: Thomas 
Guillem

mediacodec: add NDK module

The JNI module is now a submodule.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=286fa11d5024d6b35063adb950c8f1b9f7d6a9e9
---

 modules/codec/Makefile.am|2 +-
 modules/codec/omxil/mediacodec.c |   14 +-
 modules/codec/omxil/mediacodec.h |1 +
 modules/codec/omxil/mediacodec_ndk.c |  545 ++
 4 files changed, 559 insertions(+), 3 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=286fa11d5024d6b35063adb950c8f1b9f7d6a9e9
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: GetOutput: separate JNI part from Decoder part

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue May 19 12:30:12 
2015 +0200| [ac4a4aee64124bd21302c0ce6e85bcac09d04f3a] | committer: Thomas 
Guillem

mediacodec: GetOutput: separate JNI part from Decoder part

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac4a4aee64124bd21302c0ce6e85bcac09d04f3a
---

 modules/codec/omxil/mediacodec.c |  208 --
 1 file changed, 133 insertions(+), 75 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=ac4a4aee64124bd21302c0ce6e85bcac09d04f3a
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] access: extend STREAM_IS_DIRECTORY

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu May  7 09:34:27 
2015 +0200| [3840a03dbbf8a3f530fa16e0f029970881564716] | committer: Thomas 
Guillem

access: extend STREAM_IS_DIRECTORY

It now takes two new bool* arguments.

 - specify if the access returns items that are already sorted.
 - specify if directories can loop into themselves

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3840a03dbbf8a3f530fa16e0f029970881564716
---

 include/vlc_access.h   |7 +++
 include/vlc_stream.h   |2 +-
 modules/access/archive/stream.c|   11 ++-
 modules/demux/playlist/directory.c |3 ++-
 modules/demux/playlist/playlist.h  |2 +-
 src/input/demux.c  |6 +-
 src/input/stream.c |6 ++
 7 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index a23d3b1..a6a84cf 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -111,6 +111,13 @@ struct access_t
 {
 uint64_t i_pos; /* idem */
 bool b_eof; /* idem */
+
+bool b_dir_sorted; /* Set it to true if items returned by
+* pf_readdir are already sorted. */
+
+bool b_dir_can_loop;  /* Set it to true if the access can't 
know
+   * if children can loop into their 
parents.
+   * It's the case for most network 
accesses. */
 } info;
 access_sys_t *p_sys;
 
diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index a9e8586..dda58ce 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -93,7 +93,7 @@ enum stream_query_e
 STREAM_CAN_FASTSEEK,/** arg1= bool *   res=cannot fail*/
 STREAM_CAN_PAUSE,   /** arg1= bool *   res=cannot fail*/
 STREAM_CAN_CONTROL_PACE,/** arg1= bool *   res=cannot fail*/
-STREAM_IS_DIRECTORY,/** arg1= bool *   res=cannot fail*/
+STREAM_IS_DIRECTORY,/** arg1= bool *, arg2= bool *, arg3=bool *, 
res=cannot fail*/
 
 /* */
 STREAM_SET_POSITION,/** arg1= uint64_t   res=can fail  */
diff --git a/modules/access/archive/stream.c b/modules/access/archive/stream.c
index a74bf53..3b9887e 100644
--- a/modules/access/archive/stream.c
+++ b/modules/access/archive/stream.c
@@ -47,8 +47,17 @@ static int Control(stream_t *p_stream, int i_query, va_list 
args)
 switch( i_query )
 {
 case STREAM_IS_DIRECTORY:
-*va_arg( args, bool* ) = true;
+{
+bool *pb_canreaddir = va_arg( args, bool * );
+bool *pb_dirsorted = va_arg( args, bool * );
+bool *pb_dircanloop = va_arg( args, bool * );
+*pb_canreaddir = true;
+if (pb_dirsorted)
+*pb_dirsorted = false;
+if (pb_dircanloop)
+pb_dircanloop = false;
 break;
+}
 
 case STREAM_CAN_SEEK:
 case STREAM_CAN_FASTSEEK:
diff --git a/modules/demux/playlist/directory.c 
b/modules/demux/playlist/directory.c
index f614307..30b2bfa 100644
--- a/modules/demux/playlist/directory.c
+++ b/modules/demux/playlist/directory.c
@@ -44,7 +44,8 @@ int Import_Dir ( vlc_object_t *p_this)
 demux_t  *p_demux = (demux_t *)p_this;
 
 bool b_is_dir = false;
-int i_err = stream_Control( p_demux-s, STREAM_IS_DIRECTORY, b_is_dir );
+int i_err = stream_Control( p_demux-s, STREAM_IS_DIRECTORY, b_is_dir,
+NULL, NULL );
 
 if ( !( i_err == VLC_SUCCESS  b_is_dir ) )
 return VLC_EGENERIC;
diff --git a/modules/demux/playlist/playlist.h 
b/modules/demux/playlist/playlist.h
index ea6ef4b..eb3a583 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -84,7 +84,7 @@ bool CheckContentType( stream_t * p_stream, const char * 
psz_ctype );
 
 #define CHECK_FILE() do { \
 bool b_is_dir = false; \
-stream_Control( ((demux_t *)p_this)-s, STREAM_IS_DIRECTORY, b_is_dir ); \
+stream_Control( ((demux_t *)p_this)-s, STREAM_IS_DIRECTORY, b_is_dir, 
NULL, NULL ); \
 if( b_is_dir ) \
 return VLC_EGENERIC; \
 } while(0)
diff --git a/src/input/demux.c b/src/input/demux.c
index dcc6b16..ff5c1ba 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -309,7 +309,11 @@ int demux_vaControlHelper( stream_t *s,
 return stream_vaControl( s, STREAM_GET_META, args );
 
 case DEMUX_IS_PLAYLIST:
-return stream_vaControl(s, STREAM_IS_DIRECTORY, args );
+{
+bool *pb_isplaylist = va_arg( args, bool * );
+return stream_Control( s, STREAM_IS_DIRECTORY, pb_isplaylist,
+   NULL, NULL );
+}
 
 case DEMUX_GET_PTS_DELAY:
 case DEMUX_GET_FPS:
diff --git a/src/input/stream.c b/src/input/stream.c
index e220742..b74a05c 100644
--- a/src/input/stream.c
+++ b/src

[vlc-commits] move ignore-filetypes option from directory access to directory demux

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu May  7 10:19:56 
2015 +0200| [b62156ba793e968e837d8557f8dd83b586db9812] | committer: Thomas 
Guillem

move ignore-filetypes option from directory access to directory demux

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b62156ba793e968e837d8557f8dd83b586db9812
---

 modules/access/directory.c |   46 
 modules/access/fs.c|9 ---
 modules/demux/playlist/directory.c |   45 ++-
 modules/demux/playlist/playlist.c  |9 +++
 4 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index 4728fa4..2b4f6a9 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -80,7 +80,6 @@ struct directory
 struct access_sys_t
 {
 directory *current;
-char  *ignored_exts;
 char   mode;
 };
 
@@ -90,45 +89,6 @@ static int visible (const char *name)
 return name[0] != '.';
 }
 
-/**
- * Does the provided URI/path/stuff has one of the extension provided ?
- *
- * \param psz_exts A comma separated list of extension without dot, or only
- * one ext (ex: avi,mkv,webm)
- * \param psz_uri The uri/path to check (ex: file:///home/foo/bar.avi). If
- * providing an URI, it must not contain a query string.
- *
- * \return true if the uri/path has one of the provided extension
- * false otherwise.
- */
-static bool has_ext (const char *psz_exts, const char *psz_uri)
-{
-if (psz_exts == NULL)
-return false;
-
-const char *ext = strrchr (psz_uri, '.');
-if (ext == NULL)
-return false;
-
-size_t extlen = strlen (++ext);
-
-for (const char *type = psz_exts, *end; type[0]; type = end + 1)
-{
-end = strchr (type, ',');
-if (end == NULL)
-end = type + strlen (type);
-
-if (type + extlen == end  !strncasecmp (ext, type, extlen))
-return true;
-
-if (*end == '\0')
-break;
-}
-
-return false;
-}
-
-
 #ifdef HAVE_OPENAT
 /* Detect directories that recurse into themselves. */
 static bool has_inode_loop (const directory *dir, dev_t dev, ino_t inode)
@@ -298,7 +258,6 @@ int DirInit (access_t *p_access, DIR *handle)
 free (uri);
 
 p_access-p_sys = p_sys;
-p_sys-ignored_exts = var_InheritString (p_access, ignore-filetypes);
 
 p_access-pf_readdir = DirRead;
 
@@ -320,7 +279,6 @@ void DirClose( vlc_object_t * p_this )
 while (directory_pop (p_sys))
 ;
 
-free (p_sys-ignored_exts);
 free (p_sys);
 }
 
@@ -345,10 +303,6 @@ input_item_t* DirRead (access_t *p_access)
 /* Check if it is a directory or even readable */
 i_res = directory_open (p_current, psz_entry, handle);
 
-if (i_res == ENTRY_EACCESS
-|| (i_res == ENTRY_ENOTDIR  has_ext (p_sys-ignored_exts, 
psz_entry)))
-continue;
-
 /* Create an input item for the current entry */
 psz_uri = encode_URI_component (psz_entry);
 if (psz_uri == NULL
diff --git a/modules/access/fs.c b/modules/access/fs.c
index ec19c21..0c9b547 100644
--- a/modules/access/fs.c
+++ b/modules/access/fs.c
@@ -30,13 +30,6 @@
 #include fs.h
 #include vlc_plugin.h
 
-#define IGNORE_TEXT N_(Ignored extensions)
-#define IGNORE_LONGTEXT N_( \
-Files with these extensions will not be added to playlist when  \
-opening a directory.\n \
-This is useful if you add directories that contain playlist files  \
-for instance. Use a comma-separated list of extensions. )
-
 vlc_module_begin ()
 set_description( N_(File input) )
 set_shortname( N_(File) )
@@ -50,8 +43,6 @@ vlc_module_begin ()
 add_submodule()
 set_section( N_(Directory ), NULL )
 set_capability( access, 55 )
-add_string( ignore-filetypes, 
m3u,db,nfo,ini,jpg,jpeg,ljpg,gif,png,pgm,pgmyuv,pbm,pam,tga,bmp,pnm,xpm,xcf,pcx,tif,tiff,lbm,sfv,txt,sub,idx,srt,cue,ssa,
-IGNORE_TEXT, IGNORE_LONGTEXT, false )
 #ifndef HAVE_FDOPENDIR
 add_shortcut( file, directory, dir )
 #else
diff --git a/modules/demux/playlist/directory.c 
b/modules/demux/playlist/directory.c
index 0511710..54b084a 100644
--- a/modules/demux/playlist/directory.c
+++ b/modules/demux/playlist/directory.c
@@ -68,6 +68,44 @@ void Close_Dir ( vlc_object_t *p_this )
 free( p_demux-p_sys );
 }
 
+/**
+ * Does the provided URI/path/stuff has one of the extension provided ?
+ *
+ * \param psz_exts A comma separated list of extension without dot, or only
+ * one ext (ex: avi,mkv,webm)
+ * \param psz_uri The uri/path to check (ex: file:///home/foo/bar.avi). If
+ * providing an URI, it must not contain a query string.
+ *
+ * \return true if the uri/path has one of the provided extension
+ * false otherwise.
+ */
+static bool has_ext( const char *psz_exts, const char *psz_uri )
+{
+if( psz_exts == NULL )
+return false;
+
+const char *ext = strrchr

[vlc-commits] sftp: fix crash when no directory is specified

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed May  6 18:49:01 
2015 +0200| [5fe33893f31ae4611879507e9b1f4428f29d97ea] | committer: Thomas 
Guillem

sftp: fix crash when no directory is specified

Fallback to the remote Home directory.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5fe33893f31ae4611879507e9b1f4428f29d97ea
---

 modules/access/sftp.c |   41 ++---
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 43edca1..e8f7bb4 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -111,8 +111,10 @@ static int Open( vlc_object_t* p_this )
 {
 access_t*   p_access = (access_t*)p_this;
 access_sys_t* p_sys;
+const char* psz_path;
 char* psz_username = NULL;
 char* psz_password = NULL;
+char* psz_remote_home = NULL;
 int i_port;
 int i_ret;
 vlc_url_t url;
@@ -129,8 +131,7 @@ static int Open( vlc_object_t* p_this )
 p_sys-i_socket = -1;
 
 /* Parse the URL */
-const char* path = p_access-psz_location;
-vlc_UrlParse( url, path, 0 );
+vlc_UrlParse( url, p_access-psz_location, 0 );
 
 /* Check for some parameters */
 if( EMPTY_STR( url.psz_host ) )
@@ -250,18 +251,42 @@ static int Open( vlc_object_t* p_this )
 goto error;
 }
 
+/* No path, default to user Home */
+if( !url.psz_path )
+{
+const size_t i_size = 1024;
+int i_ret;
+
+psz_remote_home = malloc( i_size );
+if( !psz_remote_home )
+goto error;
+
+i_ret = libssh2_sftp_symlink_ex( p_sys-sftp_session, ., 1,
+ psz_remote_home, i_size - 1,
+ LIBSSH2_SFTP_REALPATH );
+if( i_ret = 0 )
+{
+msg_Err( p_access, Impossible to get the Home directory );
+goto error;
+}
+psz_remote_home[i_ret] = '\0';
+psz_path = psz_remote_home;
+}
+else
+psz_path = url.psz_path;
+
 /* Get some information */
 LIBSSH2_SFTP_ATTRIBUTES attributes;
-if( libssh2_sftp_stat( p_sys-sftp_session, url.psz_path, attributes ) )
+if( libssh2_sftp_stat( p_sys-sftp_session, psz_path, attributes ) )
 {
-msg_Err( p_access, Impossible to get information about the remote 
path %s, url.psz_path );
+msg_Err( p_access, Impossible to get information about the remote 
path %s, psz_path );
 goto error;
 }
 
 if( !LIBSSH2_SFTP_S_ISDIR( attributes.permissions ))
 {
 /* Open the given file */
-p_sys-file = libssh2_sftp_open( p_sys-sftp_session, url.psz_path, 
LIBSSH2_FXF_READ, 0 );
+p_sys-file = libssh2_sftp_open( p_sys-sftp_session, psz_path, 
LIBSSH2_FXF_READ, 0 );
 p_sys-filesize = attributes.filesize;
 
 ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek );
@@ -269,7 +294,7 @@ static int Open( vlc_object_t* p_this )
 else
 {
 /* Open the given directory */
-p_sys-file = libssh2_sftp_opendir( p_sys-sftp_session, url.psz_path 
);
+p_sys-file = libssh2_sftp_opendir( p_sys-sftp_session, psz_path );
 
 p_access-pf_readdir = DirRead;
 
@@ -284,7 +309,7 @@ static int Open( vlc_object_t* p_this )
 
 if( !p_sys-file )
 {
-msg_Err( p_access, Unable to open the remote path %s, url.psz_path );
+msg_Err( p_access, Unable to open the remote path %s, psz_path );
 goto error;
 }
 
@@ -292,6 +317,7 @@ static int Open( vlc_object_t* p_this )
 
 free( psz_password );
 free( psz_username );
+free( psz_remote_home );
 vlc_UrlClean( url );
 return VLC_SUCCESS;
 
@@ -302,6 +328,7 @@ error:
 libssh2_session_free( p_sys-ssh_session );
 free( psz_password );
 free( psz_username );
+free( psz_remote_home );
 vlc_UrlClean( url );
 net_Close( p_sys-i_socket );
 free( p_sys );

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] access/directory: remove recursive code

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu May  7 11:37:13 
2015 +0200| [353f77fc40ccedc951db167f5bdfaac6be2927b7] | committer: Thomas 
Guillem

access/directory: remove recursive code

Recursive parsing is not handled anymore by accesses.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=353f77fc40ccedc951db167f5bdfaac6be2927b7
---

 modules/access/directory.c |  307 
 modules/access/file.c  |6 +-
 modules/access/fs.h|1 -
 3 files changed, 85 insertions(+), 229 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=353f77fc40ccedc951db167f5bdfaac6be2927b7
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] upnp: items are already sorted

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu May  7 09:49:53 
2015 +0200| [feb2e0654099fa548c9f979c31168cd4f64575c8] | committer: Thomas 
Guillem

upnp: items are already sorted

Since items are already sorted by the server.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=feb2e0654099fa548c9f979c31168cd4f64575c8
---

 modules/services_discovery/upnp.cpp |1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/services_discovery/upnp.cpp 
b/modules/services_discovery/upnp.cpp
index f7f1882..078636d 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -839,6 +839,7 @@ static int Open( vlc_object_t *p_this )
 }
 
 p_access-pf_readdir = ReadDirectory;
+p_access-info.b_dir_sorted = true;
 
 return VLC_SUCCESS;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: add JNI module

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue May 19 18:40:21 
2015 +0200| [cae9e8d8935d65cbf4540422c2c8fee32a83b730] | committer: Thomas 
Guillem

mediacodec: add JNI module

Add the mc_api struct, used by Decoder to access a MediaCodec API.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cae9e8d8935d65cbf4540422c2c8fee32a83b730
---

 modules/codec/Makefile.am|3 +-
 modules/codec/omxil/mediacodec.c |  822 +++--
 modules/codec/omxil/mediacodec.h |   86 
 modules/codec/omxil/mediacodec_jni.c |  847 ++
 4 files changed, 1006 insertions(+), 752 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=cae9e8d8935d65cbf4540422c2c8fee32a83b730
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mediacodec: PutInput: separate JNI part from Decoder part

2015-05-20 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue May 19 09:32:21 
2015 +0200| [ebb8fafb14b6fccfb9265e327be6de948b9c0193] | committer: Thomas 
Guillem

mediacodec: PutInput: separate JNI part from Decoder part

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ebb8fafb14b6fccfb9265e327be6de948b9c0193
---

 modules/codec/omxil/mediacodec.c |  101 +-
 1 file changed, 56 insertions(+), 45 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index cb1500e..8145946 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -1140,14 +1140,15 @@ static int InsertInflightPicture(decoder_t *p_dec, 
picture_t *p_pic,
 return 0;
 }
 
-static int PutInput(decoder_t *p_dec, JNIEnv *env, const void *p_buf,
-size_t i_size, mtime_t ts, jint jflags, jlong timeout)
+static int JniPutInput(decoder_t *p_dec, JNIEnv *env, const void *p_buf,
+   size_t i_size, mtime_t ts, bool b_config, mtime_t 
timeout)
 {
 decoder_sys_t *p_sys = p_dec-p_sys;
 int index;
 uint8_t *p_mc_buf;
 jobject j_mc_buf;
 jsize j_mc_size;
+jint jflags = b_config ? BUFFER_FLAG_CODEC_CONFIG : 0;
 
 index = (*env)-CallIntMethod(env, p_sys-codec,
   jfields.dequeue_input_buffer, timeout);
@@ -1186,6 +1187,57 @@ static int PutInput(decoder_t *p_dec, JNIEnv *env, const 
void *p_buf,
 return 1;
 }
 
+static int PutInput(decoder_t *p_dec, JNIEnv *env, block_t *p_block,
+mtime_t timeout)
+{
+decoder_sys_t *p_sys = p_dec-p_sys;
+int i_ret;
+const void *p_buf;
+size_t i_size;
+bool b_config = false;
+mtime_t i_ts = 0;
+
+assert(p_sys-i_csd_send  p_sys-i_csd_count || p_block);
+
+if (p_sys-i_csd_send  p_sys-i_csd_count)
+{
+/* Try to send Codec Specific Data */
+p_buf = p_sys-p_csd[p_sys-i_csd_send].p_buf;
+i_size = p_sys-p_csd[p_sys-i_csd_send].i_size;
+b_config = true;
+} else
+{
+/* Try to send p_block input buffer */
+p_buf = p_block-p_buffer;
+i_size = p_block-i_buffer;
+i_ts = p_block-i_pts;
+if (!i_ts  p_block-i_dts)
+i_ts = p_block-i_dts;
+}
+
+i_ret = JniPutInput(p_dec, env, p_buf, i_size, i_ts, b_config, timeout);
+if (i_ret != 1)
+return i_ret;
+
+if (p_sys-i_csd_send  p_sys-i_csd_count)
+{
+msg_Dbg(p_dec, sent codec specific data(%d) of size %d 
+via BUFFER_FLAG_CODEC_CONFIG flag,
+p_sys-i_csd_send, i_size);
+p_sys-i_csd_send++;
+return 0;
+}
+else
+{
+p_sys-decoded = true;
+if (p_block-i_flags  BLOCK_FLAG_PREROLL )
+p_sys-i_preroll_end = i_ts;
+timestamp_FifoPut(p_sys-timestamp_fifo,
+  p_block-i_pts ? VLC_TS_INVALID : p_block-i_dts);
+return 1;
+}
+}
+
 static int GetOutput(decoder_t *p_dec, JNIEnv *env, picture_t *p_pic, jlong 
timeout)
 {
 decoder_sys_t *p_sys = p_dec-p_sys;
@@ -1525,50 +1577,9 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t 
**pp_block)
 if ((p_sys-i_csd_send  p_sys-i_csd_count || p_block)
   i_input_ret == 0)
 {
-const void *p_buf;
-size_t i_size;
-jint jflags = 0;
-mtime_t i_ts = 0;
-
-if (p_sys-i_csd_send  p_sys-i_csd_count)
-{
-/* Try to send Codec Specific Data */
-p_buf = p_sys-p_csd[p_sys-i_csd_send].p_buf;
-i_size = p_sys-p_csd[p_sys-i_csd_send].i_size;
-jflags = BUFFER_FLAG_CODEC_CONFIG;
-} else
-{
-/* Try to send p_block input buffer */
-p_buf = p_block-p_buffer;
-i_size = p_block-i_buffer;
-i_ts = p_block-i_pts;
-if (!i_ts  p_block-i_dts)
-i_ts = p_block-i_dts;
-}
-
-i_input_ret = PutInput(p_dec, env, p_buf, i_size, i_ts, jflags,
-   timeout);
-
-if (i_input_ret == 1)
-{
-if (p_sys-i_csd_send  p_sys-i_csd_count)
-{
-msg_Dbg(p_dec, sent codec specific data(%d) of size %d 
-via BUFFER_FLAG_CODEC_CONFIG flag,
-p_sys-i_csd_send, i_size);
-p_sys-i_csd_send++;
-i_input_ret = 0;
+i_input_ret = PutInput(p_dec, env, p_block, timeout);
+if (!p_sys-decoded)
 continue;
-}
-else
-{
-p_sys-decoded = true;
-if (p_block-i_flags  BLOCK_FLAG_PREROLL )
-p_sys-i_preroll_end = i_ts;
-timestamp_FifoPut(p_sys

[vlc-commits] audiotrack: fix multiplication cast

2015-06-09 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Jun  9 10:19:57 
2015 +0200| [0d9875366674cda470df94def0c0f28e04b394c6] | committer: Thomas 
Guillem

audiotrack: fix multiplication cast

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0d9875366674cda470df94def0c0f28e04b394c6
---

 modules/audio_output/audiotrack.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 1c9f903..34e65c4 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -809,7 +809,7 @@ AudioTrack_New( JNIEnv *env, audio_output_t *p_aout,
 i_clipped_time = VLC_CLIP( i_time, MIN_AUDIOTRACK_BUFFER_US,
  MAX_AUDIOTRACK_BUFFER_US );
 if( i_clipped_time != i_time )
-i_size = i_rate * i_clipped_time * i_bytes_per_frame / CLOCK_FREQ;
+i_size = (int)i_rate * i_clipped_time * i_bytes_per_frame / 
CLOCK_FREQ;
 }
 
 /* create AudioTrack object */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] audiotrack: print backtrace in case of exception

2015-06-08 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Jun  8 18:05:01 
2015 +0200| [0578768ed01435e7ba7f07a9211d76f569c6712e] | committer: Thomas 
Guillem

audiotrack: print backtrace in case of exception

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0578768ed01435e7ba7f07a9211d76f569c6712e
---

 modules/audio_output/audiotrack.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/audio_output/audiotrack.c 
b/modules/audio_output/audiotrack.c
index 55c975f..1c9f903 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -388,6 +388,7 @@ check_exception( JNIEnv *env, audio_output_t *p_aout,
 
 p_sys-b_audiotrack_exception = true;
 p_sys-b_error = true;
+(*env)-ExceptionDescribe( env );
 (*env)-ExceptionClear( env );
 msg_Err( p_aout, AudioTrack.%s triggered an exception !, method );
 return true;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] access: add a default pf_control for directory accesses

2015-06-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Jun  3 11:44:05 
2015 +0200| [71daa94bdabf6fa37d92c1616053f8da547cec0b] | committer: Thomas 
Guillem

access: add a default pf_control for directory accesses

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=71daa94bdabf6fa37d92c1616053f8da547cec0b
---

 include/vlc_access.h|5 +
 modules/access/directory.c  |1 +
 modules/access/dsm/access.c |1 +
 modules/access/ftp.c|1 +
 modules/access/sftp.c   |1 +
 modules/access/smb.c|1 +
 modules/services_discovery/upnp.cpp |1 +
 src/input/access.c  |   23 +++
 src/libvlccore.sym  |1 +
 9 files changed, 35 insertions(+)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index 1adf669..93b3b7c 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -162,6 +162,11 @@ static inline void access_InitFields( access_t *p_a )
  */
 VLC_API input_thread_t * access_GetParentInput( access_t *p_access ) VLC_USED;
 
+/**
+ * Default pf_control callback for directory accesses.
+ */
+VLC_API int access_vaDirectoryControlHelper( access_t *p_access, int i_query, 
va_list args );
+
 #define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
 do { \
 p_access-pf_read = (read); \
diff --git a/modules/access/directory.c b/modules/access/directory.c
index 87b5b33..2abe15a 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -93,6 +93,7 @@ int DirOpen (vlc_object_t *p_this)
 p_access-p_sys-p_dir = p_dir;
 p_access-p_sys-psz_base_uri = psz_base_uri;
 p_access-pf_readdir = DirRead;
+p_access-pf_control = access_vaDirectoryControlHelper;
 
 return VLC_SUCCESS;
 }
diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
index 8e7fcdd..6a33f3b 100644
--- a/modules/access/dsm/access.c
+++ b/modules/access/dsm/access.c
@@ -705,6 +705,7 @@ static int BrowserInit( access_t *p_access )
 p_access-pf_readdir = BrowseDirectory;
 p_access-info.b_dir_can_loop = true;
 }
+p_access-pf_control = access_vaDirectoryControlHelper;
 
 return VLC_SUCCESS;
 }
diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 096d54c..e5c5cfc 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -668,6 +668,7 @@ static int InOpen( vlc_object_t *p_this )
 if( b_directory )
 {
 p_access-pf_readdir = DirRead;
+p_access-pf_control = access_vaDirectoryControlHelper;
 p_access-info.b_dir_can_loop = true;
 } else
 ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 740da6b..b4c281a 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -296,6 +296,7 @@ static int Open( vlc_object_t* p_this )
 p_sys-file = libssh2_sftp_opendir( p_sys-sftp_session, psz_path );
 
 p_access-pf_readdir = DirRead;
+p_access-pf_control = access_vaDirectoryControlHelper;
 p_access-info.b_dir_can_loop = true;
 
 if( p_sys-file )
diff --git a/modules/access/smb.c b/modules/access/smb.c
index 3aa9902..83ce77d 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -253,6 +253,7 @@ static int Open( vlc_object_t *p_this )
 return VLC_EGENERIC;
 #else
 p_access-pf_readdir = DirRead;
+p_access-pf_control = access_vaDirectoryControlHelper;
 p_access-info.b_dir_can_loop = true;
 i_smb = smbc_opendir( psz_uri );
 i_size = 0;
diff --git a/modules/services_discovery/upnp.cpp 
b/modules/services_discovery/upnp.cpp
index 4f5aaf8..602950b 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -839,6 +839,7 @@ static int Open( vlc_object_t *p_this )
 }
 
 p_access-pf_readdir = ReadDirectory;
+p_access-pf_control = access_vaDirectoryControlHelper;
 p_access-info.b_dir_sorted = true;
 p_access-info.b_dir_can_loop = true;
 
diff --git a/src/input/access.c b/src/input/access.c
index 6b9ae13..fcab560 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -128,3 +128,26 @@ input_thread_t * access_GetParentInput( access_t *p_access 
)
 return p_access-p_input ? vlc_object_hold((vlc_object_t 
*)p_access-p_input) : NULL;
 }
 
+/*
+ * access_vaDirectoryControlHelper:
+ */
+int access_vaDirectoryControlHelper( access_t *p_access, int i_query, va_list 
args )
+{
+VLC_UNUSED( p_access );
+
+switch( i_query )
+{
+case ACCESS_CAN_SEEK:
+case ACCESS_CAN_FASTSEEK:
+case ACCESS_CAN_PAUSE:
+case ACCESS_CAN_CONTROL_PACE:
+*va_arg( args, bool* ) = false;
+break;
+case ACCESS_GET_PTS_DELAY:
+*va_arg( args, int64_t * ) = 0

[vlc-commits] mediacodec: specify NDK or JNI in description

2015-06-04 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Tue Jun  2 16:23:24 
2015 +0200| [e12376a1ccafafaeb43d56e89f2bb5481578fe02] | committer: Thomas 
Guillem

mediacodec: specify NDK or JNI in description

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e12376a1ccafafaeb43d56e89f2bb5481578fe02
---

 modules/codec/omxil/mediacodec.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 6853e60..28e41ea 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -192,7 +192,7 @@ static int InsertInflightPicture(decoder_t *, picture_t *, 
unsigned int );
 #define CFG_PREFIX mediacodec-
 
 vlc_module_begin ()
-set_description( N_(Video decoder using Android MediaCodec) )
+set_description( N_(Video decoder using Android MediaCodec via NDK) )
 set_category( CAT_INPUT )
 set_subcategory( SUBCAT_INPUT_VCODEC )
 set_section( N_(Decoding) , NULL )
@@ -202,6 +202,7 @@ vlc_module_begin ()
 set_callbacks( OpenDecoderNdk, CloseDecoder )
 add_shortcut( mediacodec_ndk )
 add_submodule ()
+set_description( N_(Video decoder using Android MediaCodec via JNI) )
 set_capability( decoder, 0 )
 set_callbacks( OpenDecoderJni, CloseDecoder )
 add_shortcut( mediacodec_jni )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] android_window: add chroma option

2015-06-22 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Mon Jun 22 16:47:05 
2015 +0200| [64ea87bec4c5dd38c0aa800a0fc37cab406002dc] | committer: Thomas 
Guillem

android_window: add chroma option

This option was previously set by androidsurface.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64ea87bec4c5dd38c0aa800a0fc37cab406002dc
---

 modules/video_output/android/android_window.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/android/android_window.c 
b/modules/video_output/android/android_window.c
index 1beef8e..2d264e0 100644
--- a/modules/video_output/android/android_window.c
+++ b/modules/video_output/android/android_window.c
@@ -47,7 +47,7 @@
 #define CHROMA_LONGTEXT N_(\
 Force use of a specific chroma for output. Default is RGB32.)
 
-#define CFG_PREFIX androidsurface-
+#define CFG_PREFIX androidwindow-
 static int  Open (vlc_object_t *);
 static void Close(vlc_object_t *);
 
@@ -58,6 +58,7 @@ vlc_module_begin()
 set_description(N_(Android video output))
 set_capability(vout display, 260)
 add_shortcut(androidwindow, android)
+add_string(CFG_PREFIX chroma, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true)
 set_callbacks(Open, Close)
 vlc_module_end()
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] android: add AWindowHandler and android_getEnv

2015-06-25 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jun 25 13:52:54 
2015 +0200| [e29f8ecf6adcc08f45a59e1790cdebcaa49db6b9] | committer: Thomas 
Guillem

android: add AWindowHandler and android_getEnv

android_getEnv: get a JNIEnv* from the Java VM passed via the android-jvm
option.

AWindowHandler: utility class that provide a way to get the Video / Subtitles
Java Surface or ANativeWindow.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e29f8ecf6adcc08f45a59e1790cdebcaa49db6b9
---

 modules/audio_output/Makefile.am  |3 +-
 modules/audio_output/audiotrack.c |   29 +-
 modules/codec/Makefile.am |4 +
 modules/codec/omxil/mediacodec.c  |   21 +-
 modules/codec/omxil/mediacodec.h  |3 +-
 modules/codec/omxil/mediacodec_jni.c  |   12 +-
 modules/codec/omxil/mediacodec_ndk.c  |   32 +-
 modules/codec/omxil/omxil.c   |   98 ++--
 modules/codec/omxil/omxil.h   |6 +-
 modules/video_output/Makefile.am  |3 +-
 modules/video_output/android/android_window.c |  267 +--
 modules/video_output/android/nativewindow.c   |   48 +-
 modules/video_output/android/utils.c  |  591 +++--
 modules/video_output/android/utils.h  |  111 -
 14 files changed, 885 insertions(+), 343 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commitdiff;h=e29f8ecf6adcc08f45a59e1790cdebcaa49db6b9
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] libvlc_media_player: create the aout when first setting audio options

2015-06-25 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Wed Jun 24 18:23:33 
2015 +0200| [1d7c55982727b20796e0d5f95434ea02b4e23614] | committer: Thomas 
Guillem

libvlc_media_player: create the aout when first setting audio options

If not setting any audio options, the aout will be created by the decoder
thread.

This avoids to create an audio output that will be destroyed if you change it
with libvlc_audio_output_set.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d7c55982727b20796e0d5f95434ea02b4e23614
---

 lib/audio.c|   17 +++--
 lib/media_player.c |4 
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/audio.c b/lib/audio.c
index 7901c64..262c8d9 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -51,7 +51,17 @@ static audio_output_t *GetAOut( libvlc_media_player_t *mp )
 
 audio_output_t *p_aout = input_resource_HoldAout( mp-input.p_resource );
 if( p_aout == NULL )
-libvlc_printerr( No active audio output );
+{
+p_aout = input_resource_GetAout( mp-input.p_resource );
+if( p_aout != NULL )
+{
+input_resource_PutAout( mp-input.p_resource, p_aout );
+p_aout = input_resource_HoldAout( mp-input.p_resource );
+}
+else
+libvlc_printerr( No active audio output );
+}
+
 return p_aout;
 }
 
@@ -133,11 +143,6 @@ int libvlc_audio_output_set( libvlc_media_player_t *mp, 
const char *psz_name )
 /* Forget the existing audio output */
 input_resource_ResetAout(mp-input.p_resource);
 
-/* Create a new audio output */
-audio_output_t *aout = input_resource_GetAout(mp-input.p_resource);
-if( aout != NULL )
-input_resource_PutAout(mp-input.p_resource, aout);
-
 return 0;
 }
 
diff --git a/lib/media_player.c b/lib/media_player.c
index f35c0cb..885c3f1 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -595,10 +595,6 @@ libvlc_media_player_new( libvlc_instance_t *instance )
 vlc_object_release(mp);
 return NULL;
 }
-audio_output_t *aout = input_resource_GetAout(mp-input.p_resource);
-if( aout != NULL )
-input_resource_PutAout(mp-input.p_resource, aout);
-
 vlc_mutex_init (mp-input.lock);
 mp-i_refcount = 1;
 mp-p_event_manager = libvlc_event_manager_new(mp, instance);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] lib: add libvlc_media_player_set_android_context

2015-06-25 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem tho...@gllm.fr | Thu Jun 25 13:52:59 
2015 +0200| [63dbabfda7fabbcb4fcfcb98548f470900a0d24d] | committer: Thomas 
Guillem

lib: add libvlc_media_player_set_android_context

Used to pass the Java VM and a org.videolan.libvlc.IAWindowNativeHandler
jobject.

 http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=63dbabfda7fabbcb4fcfcb98548f470900a0d24d
---

 include/vlc/libvlc_media_player.h |   15 +++
 lib/media_player.c|   20 
 2 files changed, 35 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h 
b/include/vlc/libvlc_media_player.h
index d24392d..3bccb5b 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -514,6 +514,21 @@ LIBVLC_API void libvlc_media_player_set_hwnd ( 
libvlc_media_player_t *p_mi, void
 LIBVLC_API void *libvlc_media_player_get_hwnd ( libvlc_media_player_t *p_mi );
 
 /**
+ * Set the android context.
+ *
+ * \version LibVLC 3.0.0 and later.
+ *
+ * \param p_mi the media player
+ * \param p_jvm the Java VM of the android process.
+ * \param awindow_handler org.videolan.libvlc.IAWindowNativeHandler jobject
+ *implemented by the org.videolan.libvlc.MediaPlayer class from the
+ *libvlc-android project.
+ */
+LIBVLC_API void libvlc_media_player_set_android_context( libvlc_media_player_t 
*p_mi,
+ void *p_jvm,
+ void 
*p_awindow_handler );
+
+/**
  * Callback prototype for audio playback.
  * \param data data pointer as passed to libvlc_audio_set_callbacks() [IN]
  * \param samples pointer to the first audio sample to play back [IN]
diff --git a/lib/media_player.c b/lib/media_player.c
index 885c3f1..09e3975 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -515,6 +515,10 @@ libvlc_media_player_new( libvlc_instance_t *instance )
 var_Create (mp, drawable-agl, VLC_VAR_INTEGER);
 var_Create (mp, drawable-nsobject, VLC_VAR_ADDRESS);
 #endif
+#ifdef __ANDROID__
+var_Create (mp, android-jvm, VLC_VAR_ADDRESS);
+var_Create (mp, drawable-androidwindow, VLC_VAR_ADDRESS);
+#endif
 
 var_Create (mp, keyboard-events, VLC_VAR_BOOL);
 var_SetBool (mp, keyboard-events, true);
@@ -1093,6 +1097,22 @@ void *libvlc_media_player_get_hwnd( 
libvlc_media_player_t *p_mi )
 #endif
 }
 
+/**
+ * set_android_context
+ **/
+void libvlc_media_player_set_android_context( libvlc_media_player_t *p_mi,
+  void *p_jvm,
+  void *p_awindow_handler )
+{
+assert (p_mi != NULL);
+#ifdef __ANDROID__
+var_SetAddress (p_mi, android-jvm, p_jvm);
+var_SetAddress (p_mi, drawable-androidwindow, p_awindow_handler);
+#else
+(void) p_mi; (void) p_jvm; (void) p_awindow_handler;
+#endif
+}
+
 void libvlc_audio_set_callbacks( libvlc_media_player_t *mp,
  libvlc_audio_play_cb play_cb,
  libvlc_audio_pause_cb pause_cb,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


<    1   2   3   4   5   6   7   8   9   10   >