[-]
[+]
|
Changed |
_service:tar_git:gmp-droid.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:gmp-droid.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/sailfishos/gmp-droid.git</param>
<param name="branch">master</param>
- <param name="revision">0.1.2</param>
+ <param name="revision">0.2</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:gmp-droid-0.1.2.tar.gz/meson_options.txt
^
|
@@ -1 +0,0 @@
-option('gecko_ver', type : 'string', description : 'Gecko version')
|
[-]
[+]
|
Changed |
_service:tar_git:gmp-droid-0.2.tar.gz/generate-info.cpp
^
|
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (c) 2020 Open Mobile Platform LLC.
+** Copyright (c) 2020-2021 Open Mobile Platform LLC.
**
** This Source Code Form is subject to the terms of the
** Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
@@ -10,45 +10,80 @@
#include "droidmediacodec.h"
#include <iostream>
+#include <vector>
using namespace std;
+typedef struct {
+ std::string androidName;
+ std::string gmpName;
+} codec_desc_t;
+
bool
-isSupported (const char *codec)
+isSupported (const codec_desc_t& codec, bool isEncoder)
{
DroidMediaCodecMetaData meta;
- meta.type = codec;
+ meta.type = codec.androidName.c_str ();
meta.flags = static_cast <DroidMediaCodecFlags> (DROID_MEDIA_CODEC_HW_ONLY);
- return droid_media_codec_is_supported (&meta, false);
+ return droid_media_codec_is_supported (&meta, isEncoder);
}
-int
-main (int argc, char **argv)
+bool
+isSupportedDecoder (const codec_desc_t& codec)
{
+ return isSupported (codec, false);
+}
- cout << "Name: gmp-droid\n" << "Description: gst-droid GMP plugin for Gecko\n"
- << "Version: 0.1\n" << "APIs: decode-video[";
+bool
+isSupportedEncoder (const codec_desc_t& codec)
+{
+ return isSupported (codec, true);
+}
+void
+printSupportedApi (std::string api, std::vector<std::string> codecs)
+{
bool first = true;
- if (isSupported ("video/avc")) {
- cout << "h264";
- first = false;
- }
- if (isSupported ("video/x-vnd.on2.vp8")) {
+
+ cout << api << "[";
+
+ for (std::string codec : codecs) {
if (!first)
cout << ":";
else
first = false;
- cout << "vp8";
+ cout << codec;
}
- if (isSupported ("video/x-vnd.on2.vp9")) {
- if (!first)
- cout << ":";
- else
- first = false;
- cout << "vp9";
+ cout << "]";
+}
+
+int
+main (int argc, char **argv)
+{
+ std::vector<codec_desc_t> codecs = {
+ { "video/avc", "h264" },
+ { "video/x-vnd.on2.vp8", "vp8" },
+ { "video/x-vnd.on2.vp9", "vp9" }
+ };
+ std::vector<std::string> supportedDecoders;
+ std::vector<std::string> supportedEncoders;
+
+ for (codec_desc_t codec : codecs) {
+ if (isSupportedDecoder (codec))
+ supportedDecoders.push_back (codec.gmpName);
+ if (isSupportedEncoder (codec))
+ supportedEncoders.push_back (codec.gmpName);
}
- cout << "]\n";
+
+ cout << "Name: gmp-droid\n"
+ << "Description: gst-droid GMP plugin for Gecko\n"
+ << "Version: 0.1\n";
+
+ cout << "APIs: ";
+ printSupportedApi ("decode-video", supportedDecoders);
+ cout << ", ";
+ printSupportedApi ("encode-video", supportedEncoders);
+ cout << "\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:gmp-droid-0.2.tar.gz/gmp-droid-conv.cpp
^
|
@@ -32,7 +32,7 @@
GMPErr Convert (GMPVideoHost * host, DroidMediaData * in,
GMPVideoi420Frame * out)
{
- int32_t size = m_width * m_height;
+ int32_t size = m_stride * m_slice_height;
uint8_t *buf = (uint8_t *) malloc (size * 3 / 2);
droid_media_convert_to_i420 (m_convert, in, buf);
out->CreateFrame (size, buf,
@@ -154,7 +154,7 @@
void SetFormat (DroidMediaRect * rect, int32_t width, int32_t height)
{
this->DroidColourConvert::SetFormat (rect, width, height);
- m_stride = ALIGN_SIZE (width, 4);
+ m_slice_height = ALIGN_SIZE (m_slice_height, 4);
}
};
@@ -229,7 +229,6 @@
}
}
- //TODO: DONT_USE_CODEC_SPECIFIED_HEIGHT/WIDTH quirks (if a device needs this)
converter->SetFormat (rect, md->width, md->height);
return converter;
}
|
[-]
[+]
|
Changed |
_service:tar_git:gmp-droid-0.2.tar.gz/gmp-droid.cpp
^
|
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (c) 2020 Open Mobile Platform LLC.
+** Copyright (c) 2020-2021 Open Mobile Platform LLC.
**
** This Source Code Form is subject to the terms of the
** Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
@@ -20,6 +20,7 @@
#include "gmp-video-host.h"
#include "gmp-video-decode.h"
+#include "gmp-video-encode.h"
#include "gmp-video-frame-i420.h"
#include "gmp-video-frame-encoded.h"
#include "gmp-droid-conv.h"
@@ -47,12 +48,6 @@
static GMPPlatformAPI *g_platform_api = nullptr;
-// Droidmedia callbacks
-static void DroidError (void *data, int err); // pass error and abord
-static int SizeChanged (void *data, int32_t width, int32_t height); // reconfigure
-static void DataAvailable (void *data, DroidMediaCodecData * decoded);
-static void SignalEOS (void *data);
-
class DroidVideoDecoder : public GMPVideoDecoder
{
public:
@@ -66,6 +61,9 @@
err = g_platform_api->createmutex (&m_stop_lock);
if (GMP_FAILED (err))
Error (err);
+ err = g_platform_api->createmutex (&m_drain_lock);
+ if (GMP_FAILED (err))
+ Error (err);
}
virtual ~DroidVideoDecoder ()
@@ -73,6 +71,7 @@
// Destroy the Mutex
m_codec_lock->Destroy ();
m_stop_lock->Destroy ();
+ m_drain_lock->Destroy ();
}
// GMPVideoDecoder methods
@@ -188,20 +187,25 @@
return;
}
- // Check that we won't run out of space in the buffer
- if (offset + len + 4 > inputFrame->Size ()) {
- LOG (ERROR,
- "Not enough space left for " << len << " bytes of NAL data");
- Error (GMPDecodeErr);
- return;
- }
- // Write NAL start code over the lenth
- static const uint8_t code[] = { 0x00, 0x00, 0x00, 0x01 };
- const uint8_t *start_code = code + (4 - start_code_len);
- memcpy (inputFrame->Buffer () + offset, start_code, start_code_len);
- offset += start_code_len + len;
- LOG (DEBUG, "Parsed nal unit of size " << len);
+ if (len == 1) {
+ // Start code already processed
+ LOG (DEBUG, "NAL start code found. Skipping");
+ break;
+ } else if (offset + len + 4 > inputFrame->Size ()) {
+ // Make sure that we won't run out of space in the buffer
+ LOG (DEBUG,
+ "NAL length more than buffer size: " << len << " bytes");
+ break;
+ } else {
+ // Write NAL start code over the length
+ static const uint8_t code[] = { 0x00, 0x00, 0x00, 0x01 };
+ const uint8_t *start_code = code + (4 - start_code_len);
+ memcpy (inputFrame->Buffer () + offset, start_code, start_code_len);
+ offset += start_code_len + len;
+
+ LOG (DEBUG, "Parsed nal unit of size " << len);
+ }
}
}
@@ -214,7 +218,7 @@
cdata.ts = inputFrame->TimeStamp ();
// Android doesn't pass duration through the codec - we'll have to keep it
- m_dur.emplace (cdata.ts, inputFrame->Duration ());
+ m_dur[cdata.ts] = inputFrame->Duration ();
cdata.sync = inputFrame->FrameType () == kGMPKeyFrame;
inputFrame->Destroy ();
@@ -235,24 +239,54 @@
void SubmitBufferThread (DroidMediaCodecData cdata,
DroidMediaBufferCallbacks cb)
{
-
+ m_drain_lock->Acquire ();
if (m_draining || (!m_codec && !CreateCodec ())) {
+ LOG (ERROR, "Buffer submitted while draining");
cb.unref (cb.data);
+ m_drain_lock->Release ();
+ return;
+ }
+ m_drain_lock->Release ();
+
+ if (m_resetting) {
+ LOG (INFO, "Buffer submitted while resetting");
return;
}
+
+ // This blocks when the input Source is full
droid_media_codec_queue (m_codec, &cdata, &cb);
+ m_drain_lock->Acquire ();
if (!m_draining && m_callback && g_platform_api) {
g_platform_api->runonmainthread (WrapTask (m_callback,
&GMPVideoDecoderCallback::InputDataExhausted));
}
+ m_drain_lock->Release ();
}
virtual void Reset ()
{
- ResetCodec ();
- m_callback->ResetComplete ();
+ m_stop_lock->Acquire ();
+ if (m_resetting) {
+ m_stop_lock->Release ();
+ return;
+ }
+
+ m_resetting = true;
+
+ if (m_processing) {
+ // Reset() will be called from DataAvailable() later
+ LOG (INFO, "Reset while m_processing");
+ m_stop_lock->Release ();
+ return;
+ }
+ if (g_platform_api) {
+ // Reset() was called. Execute it on main thread
+ g_platform_api->runonmainthread (WrapTask (this,
+ &DroidVideoDecoder::Reset_m));
+ }
+ m_stop_lock->Release ();
}
virtual void Drain ()
@@ -261,15 +295,28 @@
droid_media_codec_drain (m_codec);
}
- m_draining = true;
- //TODO: This never happens because the codec never really drains
- if (!m_codec || m_dur.size () == 0)
+ //TODO: This never happens because the codec never really drains, except for EOS
+ m_drain_lock->Acquire ();
+ if (!m_codec || m_dur.size () == 0) {
m_callback->DrainComplete ();
+ m_draining = false;
+ } else {
+ m_draining = true;
+ }
+ m_drain_lock->Release ();
}
virtual void DecodingComplete ()
{
- ResetCodec ();
+ m_callback = nullptr;
+ m_host = nullptr;
+ m_resetting = true;
+
+ if (g_platform_api) {
+ // Reset() was called. Execute it on main thread
+ g_platform_api->runonmainthread (WrapTask (this,
+ &DroidVideoDecoder::Reset_m));
+ }
}
bool CreateCodec ()
@@ -287,21 +334,21 @@
{
DroidMediaCodecCallbacks cb;
- cb.error = DroidError;
- cb.size_changed = SizeChanged;
- cb.signal_eos = SignalEOS;
+ cb.error = DroidVideoDecoder::DroidError;
+ cb.size_changed = DroidVideoDecoder::SizeChanged;
+ cb.signal_eos = DroidVideoDecoder::SignalEOS;
droid_media_codec_set_callbacks (m_codec, &cb, this);
}
{
|
[-]
[+]
|
Changed |
_service:tar_git:gmp-droid-0.2.tar.gz/meson.build
^
|
@@ -13,7 +13,7 @@
droidmedia_h = include_directories('/usr/include/droidmedia')
hybris_dep = cc.find_library('hybris-common', required: true)
-gmpdroid_install_dir = '/'.join([ get_option('libdir'), 'xulrunner-qt5-'+get_option('gecko_ver'), meson.project_name(), meson.project_version()])
+gmpdroid_install_dir = '/'.join([ get_option('libdir'), meson.project_name(), meson.project_version()])
gmp_source = [
'gmp-droid.cpp',
|