[-]
[+]
|
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">HEAD</param>
+ <param name="revision">0.2</param>
<param name="token"></param>
<param name="debian"></param>
<param name="dumb"></param>
|
[-]
[+]
|
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.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:
@@ -253,6 +248,11 @@
}
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);
@@ -271,17 +271,22 @@
m_stop_lock->Release ();
return;
}
+
m_resetting = true;
- m_stop_lock->Release ();
- if (m_codec) {
- ResetCodec ();
+ if (m_processing) {
+ // Reset() will be called from DataAvailable() later
+ LOG (INFO, "Reset while m_processing");
+ m_stop_lock->Release ();
+ return;
}
- m_drain_lock->Acquire ();
- m_draining = false;
- m_drain_lock->Release ();
- m_resetting = false;
- m_callback->ResetComplete ();
+
+ 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 ()
@@ -305,7 +310,13 @@
{
m_callback = nullptr;
m_host = nullptr;
- ResetCodec ();
+ 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 ()
@@ -323,15 +334,15 @@
{
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);
}
{
DroidMediaCodecDataCallbacks cb;
- cb.data_available = DataAvailable;
+ cb.data_available = DroidVideoDecoder::DataAvailable;
droid_media_codec_set_data_callbacks (m_codec, &cb, this);
}
// Reset state
@@ -403,25 +414,10 @@
m_codec_lock->Release ();
}
- void ProcessFrameLock (DroidMediaCodecData * decoded)
+ void ProcessFrame (DroidMediaCodecData * decoded)
{
m_stop_lock->Acquire ();
- if (m_resetting) {
- LOG (ERROR, "Received decoded frame while resetting codec");
- m_stop_lock->Release ();
- return;
- }
-
- if (g_platform_api) {
- g_platform_api->syncrunonmainthread (WrapTask (this,
- &DroidVideoDecoder::ProcessFrame, decoded));
- }
- m_stop_lock->Release ();
- }
- // Return the decoded data back to the parent.
- void ProcessFrame (DroidMediaCodecData * data)
- {
// Delete the current colour converter if requested
if (m_dropConverter) {
if (m_conv)
@@ -432,9 +428,32 @@
if (m_resetting || !m_callback || !m_host) {
LOG(INFO, "Discarding decoded frame received while resetting");
+ m_stop_lock->Release ();
return;
}
+ m_processing = true;
+ m_stop_lock->Release ();
+
+ if (g_platform_api) {
+ g_platform_api->syncrunonmainthread (WrapTask (this,
+ &DroidVideoDecoder::ProcessFrame_m, decoded));
+ }
+
+ m_stop_lock->Acquire ();
+ m_processing = false;
+ if (m_resetting && g_platform_api) {
+ // Reset() was called. Execute it on main thread
+ g_platform_api->runonmainthread (WrapTask (this,
+ &DroidVideoDecoder::Reset_m));
+ }
+ m_stop_lock->Release ();
+
+ }
+
+ // Return the decoded data back to the parent.
+ void ProcessFrame_m (DroidMediaCodecData * data)
+ {
if (!m_conv) {
ConfigureOutput (data);
}
@@ -508,6 +527,58 @@
}
private:
+
+ virtual void Reset_m ()
+ {
+ LOG (DEBUG, "Reset_m");
+ if (m_codec) {
+ ResetCodec ();
+ }
+ m_drain_lock->Acquire ();
+ m_draining = false;
+ m_drain_lock->Release ();
+ m_resetting = false;
+ if (m_callback) {
+ m_callback->ResetComplete ();
+ }
+ }
+
+ /*
+ * Droidmedia callbacks
+ */
+ static void
+ DataAvailable (void *data, DroidMediaCodecData * decoded)
+ {
+ DroidVideoDecoder *decoder = (DroidVideoDecoder *) data;
+ decoder->ProcessFrame (decoded);
+ }
+
+ static int
+ SizeChanged (void *data, int32_t width, int32_t height)
+ {
|