Allow Video Callback to Fail

This commit is contained in:
Florian Märkl 2019-11-01 17:00:28 +01:00
commit 34b7d61295
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
8 changed files with 33 additions and 16 deletions

View file

@ -24,7 +24,7 @@
#include <oboe/Oboe.h>
#define BUFFER_CHUNK_SIZE 512
#define BUFFER_CHUNK_SIZE 1024
#define BUFFER_CHUNKS_COUNT 32
using AudioBuffer = CircularBuffer<BUFFER_CHUNKS_COUNT, BUFFER_CHUNK_SIZE>;

View file

@ -262,7 +262,7 @@ JNIEXPORT void JNICALL JNI_FCN(sessionCreate)(JNIEnv *env, jobject obj, jobject
}
memset(session, 0, sizeof(AndroidChiakiSession));
session->log = log;
err = android_chiaki_video_decoder_init(&session->video_decoder, log);
err = android_chiaki_video_decoder_init(&session->video_decoder, log, connect_info.video_profile.width, connect_info.video_profile.height);
if(err != CHIAKI_ERR_SUCCESS)
{
free(session);

View file

@ -29,11 +29,13 @@
static void *android_chiaki_video_decoder_output_thread_func(void *user);
ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log)
ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log, int32_t target_width, int32_t target_height)
{
decoder->log = log;
decoder->codec = NULL;
decoder->timestamp_cur = 0;
decoder->target_width = target_width;
decoder->target_height = target_height;
return chiaki_mutex_init(&decoder->codec_mutex, false);
}
@ -91,8 +93,8 @@ void android_chiaki_video_decoder_set_surface(AndroidChiakiVideoDecoder *decoder
AMediaFormat *format = AMediaFormat_new();
AMediaFormat_setString(format, AMEDIAFORMAT_KEY_MIME, mime);
AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_WIDTH, 1280); // TODO: correct values
AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_HEIGHT, 720);
AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_WIDTH, decoder->target_width);
AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_HEIGHT, decoder->target_height);
media_status_t r = AMediaCodec_configure(decoder->codec, format, decoder->window, NULL, 0);
if(r != AMEDIA_OK)
@ -131,8 +133,9 @@ beach:
chiaki_mutex_unlock(&decoder->codec_mutex);
}
void android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user)
bool android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user)
{
bool r = true;
AndroidChiakiVideoDecoder *decoder = user;
chiaki_mutex_lock(&decoder->codec_mutex);
@ -148,7 +151,7 @@ void android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, vo
if(codec_buf_index < 0)
{
CHIAKI_LOGE(decoder->log, "Failed to get input buffer");
// TODO: report corrupt
r = false;
goto beach;
}
@ -173,6 +176,7 @@ void android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, vo
beach:
chiaki_mutex_unlock(&decoder->codec_mutex);
return r;
}
static void *android_chiaki_video_decoder_output_thread_func(void *user)

View file

@ -34,11 +34,13 @@ typedef struct android_chiaki_video_decoder_t
ANativeWindow *window;
uint64_t timestamp_cur;
ChiakiThread output_thread;
int32_t target_width;
int32_t target_height;
} AndroidChiakiVideoDecoder;
ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log);
ChiakiErrorCode android_chiaki_video_decoder_init(AndroidChiakiVideoDecoder *decoder, ChiakiLog *log, int32_t target_width, int32_t target_height);
void android_chiaki_video_decoder_fini(AndroidChiakiVideoDecoder *decoder);
void android_chiaki_video_decoder_set_surface(AndroidChiakiVideoDecoder *decoder, JNIEnv *env, jobject surface);
void android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user);
bool android_chiaki_video_decoder_video_sample(uint8_t *buf, size_t buf_size, void *user);
#endif

View file

@ -43,7 +43,7 @@ class StreamInput(val preferences: Preferences)
fun dispatchKeyEvent(event: KeyEvent): Boolean
{
Log.i("StreamSession", "key event $event")
//Log.i("StreamSession", "key event $event")
if(event.action != KeyEvent.ACTION_DOWN && event.action != KeyEvent.ACTION_UP)
return false