mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1086693 - Part 6: Use generated bindings for AndroidMediaCodec and AndroidSurfaceTexture r=blassey,gcp
This commit is contained in:
parent
82a61c55cc
commit
947ae1c3a2
@ -3,13 +3,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "AndroidDecoderModule.h"
|
#include "AndroidDecoderModule.h"
|
||||||
#include "PlatformDecoderModule.h"
|
|
||||||
#include "GeneratedJNIWrappers.h"
|
|
||||||
#include "GeneratedSDKWrappers.h"
|
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
#include "MediaTaskQueue.h"
|
|
||||||
#include "SharedThreadPool.h"
|
|
||||||
#include "TexturePoolOGL.h"
|
|
||||||
#include "GLImages.h"
|
#include "GLImages.h"
|
||||||
|
|
||||||
#include "MediaData.h"
|
#include "MediaData.h"
|
||||||
@ -26,7 +20,7 @@
|
|||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::gl;
|
using namespace mozilla::gl;
|
||||||
using namespace mozilla::widget::android;
|
using namespace mozilla::widget::android::sdk;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
@ -36,10 +30,7 @@ static MediaCodec* CreateDecoder(JNIEnv* aEnv, const char* aMimeType)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString mimeType;
|
jobject decoder = MediaCodec::CreateDecoderByType(nsCString(aMimeType));
|
||||||
mimeType.AssignASCII(aMimeType);
|
|
||||||
|
|
||||||
jobject decoder = MediaCodec::CreateDecoderByType(mimeType);
|
|
||||||
|
|
||||||
return new MediaCodec(decoder, aEnv);
|
return new MediaCodec(decoder, aEnv);
|
||||||
}
|
}
|
||||||
@ -103,7 +94,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
layers::ImageContainer* mImageContainer;
|
layers::ImageContainer* mImageContainer;
|
||||||
const mp4_demuxer::VideoDecoderConfig& mConfig;
|
const mp4_demuxer::VideoDecoderConfig& mConfig;
|
||||||
nsRefPtr<AndroidSurfaceTexture> mSurfaceTexture;
|
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioDataDecoder : public MediaCodecDataDecoder {
|
class AudioDataDecoder : public MediaCodecDataDecoder {
|
||||||
@ -115,11 +106,11 @@ public:
|
|||||||
|
|
||||||
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE {
|
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE {
|
||||||
if (!strcmp(mMimeType, "audio/mp4a-latm")) {
|
if (!strcmp(mMimeType, "audio/mp4a-latm")) {
|
||||||
uint32_t numChannels = mFormat->GetInteger(NS_LITERAL_STRING("channel-count"));
|
uint32_t numChannels = mFormat->GetInteger(NS_LITERAL_CSTRING("channel-count"));
|
||||||
uint32_t sampleRate = mFormat->GetInteger(NS_LITERAL_STRING("sample-rate"));
|
uint32_t sampleRate = mFormat->GetInteger(NS_LITERAL_CSTRING("sample-rate"));
|
||||||
uint8_t frequencyIndex =
|
uint8_t frequencyIndex =
|
||||||
mp4_demuxer::Adts::GetFrequencyIndex(sampleRate);
|
mp4_demuxer::Adts::GetFrequencyIndex(sampleRate);
|
||||||
uint32_t aacProfile = mFormat->GetInteger(NS_LITERAL_STRING("aac-profile"));
|
uint32_t aacProfile = mFormat->GetInteger(NS_LITERAL_CSTRING("aac-profile"));
|
||||||
bool rv = mp4_demuxer::Adts::ConvertSample(numChannels,
|
bool rv = mp4_demuxer::Adts::ConvertSample(numChannels,
|
||||||
frequencyIndex,
|
frequencyIndex,
|
||||||
aacProfile,
|
aacProfile,
|
||||||
@ -135,8 +126,8 @@ public:
|
|||||||
nsresult Output(BufferInfo* aInfo, void* aBuffer, MediaFormat* aFormat, Microseconds aDuration) {
|
nsresult Output(BufferInfo* aInfo, void* aBuffer, MediaFormat* aFormat, Microseconds aDuration) {
|
||||||
// The output on Android is always 16-bit signed
|
// The output on Android is always 16-bit signed
|
||||||
|
|
||||||
uint32_t numChannels = aFormat->GetInteger(NS_LITERAL_STRING("channel-count"));
|
uint32_t numChannels = aFormat->GetInteger(NS_LITERAL_CSTRING("channel-count"));
|
||||||
uint32_t sampleRate = aFormat->GetInteger(NS_LITERAL_STRING("sample-rate"));
|
uint32_t sampleRate = aFormat->GetInteger(NS_LITERAL_CSTRING("sample-rate"));
|
||||||
uint32_t numFrames = (aInfo->getSize() / numChannels) / 2;
|
uint32_t numFrames = (aInfo->getSize() / numChannels) / 2;
|
||||||
|
|
||||||
AudioDataValue* audio = new AudioDataValue[aInfo->getSize()];
|
AudioDataValue* audio = new AudioDataValue[aInfo->getSize()];
|
||||||
@ -169,10 +160,7 @@ AndroidDecoderModule::CreateH264Decoder(
|
|||||||
MediaTaskQueue* aVideoTaskQueue,
|
MediaTaskQueue* aVideoTaskQueue,
|
||||||
MediaDataDecoderCallback* aCallback)
|
MediaDataDecoderCallback* aCallback)
|
||||||
{
|
{
|
||||||
nsAutoString mimeType;
|
jobject jFormat = MediaFormat::CreateVideoFormat(nsCString(aConfig.mime_type),
|
||||||
mimeType.AssignASCII(aConfig.mime_type);
|
|
||||||
|
|
||||||
jobject jFormat = MediaFormat::CreateVideoFormat(mimeType,
|
|
||||||
aConfig.display_width,
|
aConfig.display_width,
|
||||||
aConfig.display_height);
|
aConfig.display_height);
|
||||||
|
|
||||||
@ -199,10 +187,7 @@ AndroidDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig&
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(aConfig.bits_per_sample == 16, "We only handle 16-bit audio!");
|
MOZ_ASSERT(aConfig.bits_per_sample == 16, "We only handle 16-bit audio!");
|
||||||
|
|
||||||
nsAutoString mimeType;
|
jobject jFormat = MediaFormat::CreateAudioFormat(nsCString(aConfig.mime_type),
|
||||||
mimeType.AssignASCII(aConfig.mime_type);
|
|
||||||
|
|
||||||
jobject jFormat = MediaFormat::CreateAudioFormat(mimeType,
|
|
||||||
aConfig.samples_per_second,
|
aConfig.samples_per_second,
|
||||||
aConfig.channel_count);
|
aConfig.channel_count);
|
||||||
|
|
||||||
@ -216,21 +201,21 @@ AndroidDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig&
|
|||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
JNIEnv* env = GetJNIForThread();
|
||||||
|
|
||||||
if (!format->GetByteBuffer(NS_LITERAL_STRING("csd-0"))) {
|
if (!format->GetByteBuffer(NS_LITERAL_CSTRING("csd-0"))) {
|
||||||
uint8_t* csd0 = new uint8_t[2];
|
uint8_t* csd0 = new uint8_t[2];
|
||||||
|
|
||||||
csd0[0] = aConfig.audio_specific_config[0];
|
csd0[0] = aConfig.audio_specific_config[0];
|
||||||
csd0[1] = aConfig.audio_specific_config[1];
|
csd0[1] = aConfig.audio_specific_config[1];
|
||||||
|
|
||||||
jobject buffer = env->NewDirectByteBuffer(csd0, 2);
|
jobject buffer = env->NewDirectByteBuffer(csd0, 2);
|
||||||
format->SetByteBuffer(NS_LITERAL_STRING("csd-0"), buffer);
|
format->SetByteBuffer(NS_LITERAL_CSTRING("csd-0"), buffer);
|
||||||
|
|
||||||
env->DeleteLocalRef(buffer);
|
env->DeleteLocalRef(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mimeType.EqualsLiteral("audio/mp4a-latm")) {
|
if (strcmp(aConfig.mime_type, "audio/mp4a-latm") == 0) {
|
||||||
format->SetInteger(NS_LITERAL_STRING("is-adts"), 1);
|
format->SetInteger(NS_LITERAL_CSTRING("is-adts"), 1);
|
||||||
format->SetInteger(NS_LITERAL_STRING("aac-profile"), aConfig.aac_profile);
|
format->SetInteger(NS_LITERAL_CSTRING("aac-profile"), aConfig.aac_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<MediaDataDecoder> decoder =
|
nsRefPtr<MediaDataDecoder> decoder =
|
||||||
@ -294,15 +279,26 @@ nsresult MediaCodecDataDecoder::InitDecoder(jobject aSurface)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mDecoder->Configure(mFormat->wrappedObject(), aSurface, nullptr, 0)) {
|
nsresult res;
|
||||||
mCallback->Error();
|
mDecoder->Configure(mFormat->wrappedObject(), aSurface, nullptr, 0, &res);
|
||||||
return NS_ERROR_FAILURE;
|
if (NS_FAILED(res)) {
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDecoder->Start();
|
mDecoder->Start(&res);
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
ResetInputBuffers();
|
res = ResetInputBuffers();
|
||||||
ResetOutputBuffers();
|
if (NS_FAILED(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = ResetOutputBuffers();
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
NS_NewNamedThread("MC Decoder", getter_AddRefs(mThread),
|
NS_NewNamedThread("MC Decoder", getter_AddRefs(mThread),
|
||||||
NS_NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop));
|
NS_NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop));
|
||||||
@ -321,6 +317,7 @@ void MediaCodecDataDecoder::DecoderLoop()
|
|||||||
mp4_demuxer::MP4Sample* sample = nullptr;
|
mp4_demuxer::MP4Sample* sample = nullptr;
|
||||||
|
|
||||||
nsAutoPtr<MediaFormat> outputFormat;
|
nsAutoPtr<MediaFormat> outputFormat;
|
||||||
|
nsresult res;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
{
|
{
|
||||||
@ -354,7 +351,13 @@ void MediaCodecDataDecoder::DecoderLoop()
|
|||||||
|
|
||||||
if (sample) {
|
if (sample) {
|
||||||
// We have a sample, try to feed it to the decoder
|
// We have a sample, try to feed it to the decoder
|
||||||
int inputIndex = mDecoder->DequeueInputBuffer(DECODER_TIMEOUT);
|
int inputIndex = mDecoder->DequeueInputBuffer(DECODER_TIMEOUT, &res);
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
printf_stderr("exiting decoder loop due to exception while dequeuing input\n");
|
||||||
|
mCallback->Error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (inputIndex >= 0) {
|
if (inputIndex >= 0) {
|
||||||
jobject buffer = env->GetObjectArrayElement(mInputBuffers, inputIndex);
|
jobject buffer = env->GetObjectArrayElement(mInputBuffers, inputIndex);
|
||||||
void* directBuffer = env->GetDirectBufferAddress(buffer);
|
void* directBuffer = env->GetDirectBufferAddress(buffer);
|
||||||
@ -369,7 +372,13 @@ void MediaCodecDataDecoder::DecoderLoop()
|
|||||||
|
|
||||||
PodCopy((uint8_t*)directBuffer, sample->data, sample->size);
|
PodCopy((uint8_t*)directBuffer, sample->data, sample->size);
|
||||||
|
|
||||||
mDecoder->QueueInputBuffer(inputIndex, 0, sample->size, sample->composition_timestamp, 0);
|
mDecoder->QueueInputBuffer(inputIndex, 0, sample->size, sample->composition_timestamp, 0, &res);
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
printf_stderr("exiting decoder loop due to exception while queuing input\n");
|
||||||
|
mCallback->Error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
mDurations.push(sample->duration);
|
mDurations.push(sample->duration);
|
||||||
|
|
||||||
delete sample;
|
delete sample;
|
||||||
@ -383,12 +392,23 @@ void MediaCodecDataDecoder::DecoderLoop()
|
|||||||
if (!outputDone) {
|
if (!outputDone) {
|
||||||
BufferInfo bufferInfo;
|
BufferInfo bufferInfo;
|
||||||
|
|
||||||
int outputStatus = mDecoder->DequeueOutputBuffer(bufferInfo.wrappedObject(), DECODER_TIMEOUT);
|
int outputStatus = mDecoder->DequeueOutputBuffer(bufferInfo.wrappedObject(), DECODER_TIMEOUT, &res);
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
printf_stderr("exiting decoder loop due to exception while dequeuing output\n");
|
||||||
|
mCallback->Error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (outputStatus == MediaCodec::getINFO_TRY_AGAIN_LATER()) {
|
if (outputStatus == MediaCodec::getINFO_TRY_AGAIN_LATER()) {
|
||||||
// We might want to call mCallback->InputExhausted() here, but there seems to be
|
// We might want to call mCallback->InputExhausted() here, but there seems to be
|
||||||
// some possible bad interactions here with the threading
|
// some possible bad interactions here with the threading
|
||||||
} else if (outputStatus == MediaCodec::getINFO_OUTPUT_BUFFERS_CHANGED()) {
|
} else if (outputStatus == MediaCodec::getINFO_OUTPUT_BUFFERS_CHANGED()) {
|
||||||
ResetOutputBuffers();
|
res = ResetOutputBuffers();
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
printf_stderr("exiting decoder loop due to exception while restting output buffers\n");
|
||||||
|
mCallback->Error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (outputStatus == MediaCodec::getINFO_OUTPUT_FORMAT_CHANGED()) {
|
} else if (outputStatus == MediaCodec::getINFO_OUTPUT_FORMAT_CHANGED()) {
|
||||||
outputFormat = new MediaFormat(mDecoder->GetOutputFormat(), GetJNIForThread());
|
outputFormat = new MediaFormat(mDecoder->GetOutputFormat(), GetJNIForThread());
|
||||||
} else if (outputStatus < 0) {
|
} else if (outputStatus < 0) {
|
||||||
@ -454,7 +474,7 @@ nsresult MediaCodecDataDecoder::Input(mp4_demuxer::MP4Sample* aSample) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaCodecDataDecoder::ResetInputBuffers()
|
nsresult MediaCodecDataDecoder::ResetInputBuffers()
|
||||||
{
|
{
|
||||||
JNIEnv* env = GetJNIForThread();
|
JNIEnv* env = GetJNIForThread();
|
||||||
|
|
||||||
@ -462,10 +482,16 @@ void MediaCodecDataDecoder::ResetInputBuffers()
|
|||||||
env->DeleteGlobalRef(mInputBuffers);
|
env->DeleteGlobalRef(mInputBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
mInputBuffers = (jobjectArray) env->NewGlobalRef(mDecoder->GetInputBuffers());
|
nsresult res;
|
||||||
|
mInputBuffers = (jobjectArray) env->NewGlobalRef(mDecoder->GetInputBuffers(&res));
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaCodecDataDecoder::ResetOutputBuffers()
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult MediaCodecDataDecoder::ResetOutputBuffers()
|
||||||
{
|
{
|
||||||
JNIEnv* env = GetJNIForThread();
|
JNIEnv* env = GetJNIForThread();
|
||||||
|
|
||||||
@ -473,7 +499,13 @@ void MediaCodecDataDecoder::ResetOutputBuffers()
|
|||||||
env->DeleteGlobalRef(mOutputBuffers);
|
env->DeleteGlobalRef(mOutputBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutputBuffers = (jobjectArray) env->NewGlobalRef(mDecoder->GetOutputBuffers());
|
nsresult res;
|
||||||
|
mOutputBuffers = (jobjectArray) env->NewGlobalRef(mDecoder->GetOutputBuffers(&res));
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult MediaCodecDataDecoder::Flush() {
|
nsresult MediaCodecDataDecoder::Flush() {
|
||||||
@ -515,6 +547,7 @@ nsresult MediaCodecDataDecoder::Shutdown() {
|
|||||||
|
|
||||||
mDecoder->Stop();
|
mDecoder->Stop();
|
||||||
mDecoder->Release();
|
mDecoder->Release();
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,9 @@
|
|||||||
#define AndroidDecoderModule_h_
|
#define AndroidDecoderModule_h_
|
||||||
|
|
||||||
#include "PlatformDecoderModule.h"
|
#include "PlatformDecoderModule.h"
|
||||||
#include "AndroidJavaWrappers.h"
|
|
||||||
#include "AndroidSurfaceTexture.h"
|
#include "AndroidSurfaceTexture.h"
|
||||||
|
|
||||||
#include "GeneratedSDKWrappers.h"
|
#include "MediaCodec.h"
|
||||||
#include "mozilla/Monitor.h"
|
#include "mozilla/Monitor.h"
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@ -20,11 +19,13 @@ typedef std::queue<mp4_demuxer::MP4Sample*> SampleQueue;
|
|||||||
|
|
||||||
namespace widget {
|
namespace widget {
|
||||||
namespace android {
|
namespace android {
|
||||||
|
namespace sdk {
|
||||||
class MediaCodec;
|
class MediaCodec;
|
||||||
class MediaFormat;
|
class MediaFormat;
|
||||||
class ByteBuffer;
|
class ByteBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MediaCodecDataDecoder;
|
class MediaCodecDataDecoder;
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ public:
|
|||||||
|
|
||||||
MediaCodecDataDecoder(MediaData::Type aType,
|
MediaCodecDataDecoder(MediaData::Type aType,
|
||||||
const char* aMimeType,
|
const char* aMimeType,
|
||||||
mozilla::widget::android::MediaFormat* aFormat,
|
mozilla::widget::android::sdk::MediaFormat* aFormat,
|
||||||
MediaDataDecoderCallback* aCallback);
|
MediaDataDecoderCallback* aCallback);
|
||||||
|
|
||||||
virtual ~MediaCodecDataDecoder();
|
virtual ~MediaCodecDataDecoder();
|
||||||
@ -73,11 +74,11 @@ protected:
|
|||||||
MediaData::Type mType;
|
MediaData::Type mType;
|
||||||
|
|
||||||
nsAutoPtr<char> mMimeType;
|
nsAutoPtr<char> mMimeType;
|
||||||
nsAutoPtr<mozilla::widget::android::MediaFormat> mFormat;
|
nsAutoPtr<mozilla::widget::android::sdk::MediaFormat> mFormat;
|
||||||
|
|
||||||
MediaDataDecoderCallback* mCallback;
|
MediaDataDecoderCallback* mCallback;
|
||||||
|
|
||||||
nsAutoPtr<mozilla::widget::android::MediaCodec> mDecoder;
|
nsAutoPtr<mozilla::widget::android::sdk::MediaCodec> mDecoder;
|
||||||
|
|
||||||
jobjectArray mInputBuffers;
|
jobjectArray mInputBuffers;
|
||||||
jobjectArray mOutputBuffers;
|
jobjectArray mOutputBuffers;
|
||||||
@ -94,11 +95,11 @@ protected:
|
|||||||
|
|
||||||
virtual nsresult InitDecoder(jobject aSurface = nullptr);
|
virtual nsresult InitDecoder(jobject aSurface = nullptr);
|
||||||
|
|
||||||
virtual nsresult Output(mozilla::widget::android::BufferInfo* aInfo, void* aBuffer, mozilla::widget::android::MediaFormat* aFormat, Microseconds aDuration) { return NS_OK; }
|
virtual nsresult Output(mozilla::widget::android::sdk::BufferInfo* aInfo, void* aBuffer, mozilla::widget::android::sdk::MediaFormat* aFormat, Microseconds aDuration) { return NS_OK; }
|
||||||
virtual nsresult PostOutput(mozilla::widget::android::BufferInfo* aInfo, mozilla::widget::android::MediaFormat* aFormat, Microseconds aDuration) { return NS_OK; }
|
virtual nsresult PostOutput(mozilla::widget::android::sdk::BufferInfo* aInfo, mozilla::widget::android::sdk::MediaFormat* aFormat, Microseconds aDuration) { return NS_OK; }
|
||||||
|
|
||||||
void ResetInputBuffers();
|
nsresult ResetInputBuffers();
|
||||||
void ResetOutputBuffers();
|
nsresult ResetOutputBuffers();
|
||||||
|
|
||||||
void DecoderLoop();
|
void DecoderLoop();
|
||||||
virtual void ClearQueue();
|
virtual void ClearQueue();
|
||||||
|
@ -952,7 +952,7 @@ void nsNPAPIPluginInstance::ReleaseContentTexture(nsNPAPIPluginInstance::Texture
|
|||||||
mContentTexture->Release(aTextureInfo);
|
mContentTexture->Release(aTextureInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidSurfaceTexture* nsNPAPIPluginInstance::CreateSurfaceTexture()
|
TemporaryRef<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
|
||||||
{
|
{
|
||||||
if (!EnsureGLContext())
|
if (!EnsureGLContext())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -961,14 +961,15 @@ AndroidSurfaceTexture* nsNPAPIPluginInstance::CreateSurfaceTexture()
|
|||||||
if (!texture)
|
if (!texture)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
AndroidSurfaceTexture* surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
|
RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
|
||||||
texture);
|
texture);
|
||||||
if (!surface)
|
if (!surface) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIRunnable> frameCallback = NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
|
nsCOMPtr<nsIRunnable> frameCallback = NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
|
||||||
surface->SetFrameAvailableCallback(frameCallback);
|
surface->SetFrameAvailableCallback(frameCallback);
|
||||||
return surface;
|
return surface.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
|
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
|
||||||
@ -1009,9 +1010,10 @@ nsNPAPIPluginInstance::AsSurfaceTexture()
|
|||||||
|
|
||||||
void* nsNPAPIPluginInstance::AcquireVideoWindow()
|
void* nsNPAPIPluginInstance::AcquireVideoWindow()
|
||||||
{
|
{
|
||||||
AndroidSurfaceTexture* surface = CreateSurfaceTexture();
|
RefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
|
||||||
if (!surface)
|
if (!surface) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
VideoInfo* info = new VideoInfo(surface);
|
VideoInfo* info = new VideoInfo(surface);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public:
|
|||||||
mSurfaceTexture = nullptr;
|
mSurfaceTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
|
mozilla::RefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
|
||||||
gfxRect mDimensions;
|
gfxRect mDimensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -328,8 +328,8 @@ protected:
|
|||||||
bool mFullScreen;
|
bool mFullScreen;
|
||||||
bool mInverted;
|
bool mInverted;
|
||||||
|
|
||||||
nsRefPtr<SharedPluginTexture> mContentTexture;
|
mozilla::RefPtr<SharedPluginTexture> mContentTexture;
|
||||||
nsRefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
|
mozilla::RefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -378,7 +378,7 @@ private:
|
|||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
void EnsureSharedTexture();
|
void EnsureSharedTexture();
|
||||||
mozilla::gl::AndroidSurfaceTexture* CreateSurfaceTexture();
|
mozilla::TemporaryRef<mozilla::gl::AndroidSurfaceTexture> CreateSurfaceTexture();
|
||||||
|
|
||||||
std::map<void*, VideoInfo*> mVideos;
|
std::map<void*, VideoInfo*> mVideos;
|
||||||
bool mOnScreen;
|
bool mOnScreen;
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "mozilla/gfx/Matrix.h"
|
#include "mozilla/gfx/Matrix.h"
|
||||||
#include "GeneratedJNIWrappers.h"
|
#include "GeneratedJNIWrappers.h"
|
||||||
|
#include "SurfaceTexture.h"
|
||||||
#include "GLContext.h"
|
#include "GLContext.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::widget::android;
|
using namespace mozilla::widget::android;
|
||||||
|
using namespace mozilla::widget::android::sdk;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
@ -39,92 +41,164 @@ IsSTSupported()
|
|||||||
return AndroidBridge::Bridge()->GetAPIVersion() >= 14; /* ICS */
|
return AndroidBridge::Bridge()->GetAPIVersion() >= 14; /* ICS */
|
||||||
}
|
}
|
||||||
|
|
||||||
static class JNIFunctions {
|
TemporaryRef<AndroidSurfaceTexture>
|
||||||
public:
|
AndroidSurfaceTexture::Create()
|
||||||
|
|
||||||
JNIFunctions() : mInitialized(false)
|
|
||||||
{
|
{
|
||||||
|
return Create(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnsureInitialized()
|
TemporaryRef<AndroidSurfaceTexture>
|
||||||
|
AndroidSurfaceTexture::Create(GLContext* aContext, GLuint aTexture)
|
||||||
{
|
{
|
||||||
if (mInitialized) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsSTSupported()) {
|
if (!IsSTSupported()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<AndroidSurfaceTexture> st = new AndroidSurfaceTexture();
|
||||||
|
if (!st->Init(aContext, aTexture)) {
|
||||||
|
printf_stderr("Failed to initialize AndroidSurfaceTexture");
|
||||||
|
st = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return st.forget();
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidSurfaceTexture*
|
||||||
|
AndroidSurfaceTexture::Find(int id)
|
||||||
|
{
|
||||||
|
std::map<int, AndroidSurfaceTexture*>::iterator it;
|
||||||
|
|
||||||
|
it = sInstances.find(id);
|
||||||
|
if (it == sInstances.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
AndroidSurfaceTexture::Attach(GLContext* aContext, PRIntervalTime aTimeout)
|
||||||
|
{
|
||||||
|
MonitorAutoLock lock(mMonitor);
|
||||||
|
|
||||||
|
if (mAttachedContext == aContext) {
|
||||||
|
NS_WARNING("Tried to attach same GLContext to AndroidSurfaceTexture");
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsDetachSupported()) {
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (mAttachedContext) {
|
||||||
|
// Wait until it's detached (or we time out)
|
||||||
|
if (NS_FAILED(lock.Wait(aTimeout))) {
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(aContext->IsOwningThreadCurrent(), "Trying to attach GLContext from different thread");
|
||||||
|
|
||||||
|
mAttachedContext = aContext;
|
||||||
|
mAttachedContext->MakeCurrent();
|
||||||
|
aContext->fGenTextures(1, &mTexture);
|
||||||
|
|
||||||
|
nsresult res;
|
||||||
|
mSurfaceTexture->AttachToGLContext(mTexture, &res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
AndroidSurfaceTexture::Detach()
|
||||||
|
{
|
||||||
|
MonitorAutoLock lock(mMonitor);
|
||||||
|
|
||||||
|
if (!IsDetachSupported() ||
|
||||||
|
!mAttachedContext || !mAttachedContext->IsOwningThreadCurrent()) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAttachedContext->MakeCurrent();
|
||||||
|
|
||||||
|
mSurfaceTexture->DetachFromGLContext();
|
||||||
|
|
||||||
|
mTexture = 0;
|
||||||
|
mAttachedContext = nullptr;
|
||||||
|
lock.NotifyAll();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
|
||||||
|
{
|
||||||
|
if (!aTexture && !IsDetachSupported()) {
|
||||||
|
// We have no texture and cannot initialize detached, bail out
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
nsresult res;
|
||||||
|
mSurfaceTexture = new SurfaceTexture(aTexture, &res);
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
if (NS_FAILED(res)) {
|
||||||
|
return false;
|
||||||
jSurfaceTextureClass = (jclass)env->NewGlobalRef(env->FindClass("android/graphics/SurfaceTexture"));
|
|
||||||
jSurfaceTexture_Ctor = env->GetMethodID(jSurfaceTextureClass, "<init>", "(I)V");
|
|
||||||
jSurfaceTexture_updateTexImage = env->GetMethodID(jSurfaceTextureClass, "updateTexImage", "()V");
|
|
||||||
jSurfaceTexture_getTransformMatrix = env->GetMethodID(jSurfaceTextureClass, "getTransformMatrix", "([F)V");
|
|
||||||
jSurfaceTexture_setDefaultBufferSize = env->GetMethodID(jSurfaceTextureClass, "setDefaultBufferSize", "(II)V");
|
|
||||||
|
|
||||||
if (IsDetachSupported()) {
|
|
||||||
jSurfaceTexture_attachToGLContext = env->GetMethodID(jSurfaceTextureClass, "attachToGLContext", "(I)V");
|
|
||||||
jSurfaceTexture_detachFromGLContext = env->GetMethodID(jSurfaceTextureClass, "detachFromGLContext", "()V");
|
|
||||||
} else {
|
|
||||||
jSurfaceTexture_attachToGLContext = jSurfaceTexture_detachFromGLContext = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jSurfaceClass = (jclass)env->NewGlobalRef(env->FindClass("android/view/Surface"));
|
if (!aTexture) {
|
||||||
jSurface_Ctor = env->GetMethodID(jSurfaceClass, "<init>", "(Landroid/graphics/SurfaceTexture;)V");
|
mSurfaceTexture->DetachFromGLContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
mAttachedContext = aContext;
|
||||||
|
|
||||||
|
mSurface = new Surface(mSurfaceTexture->wrappedObject(), &res);
|
||||||
|
if (NS_FAILED(res)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mNativeWindow = AndroidNativeWindow::CreateFromSurface(GetJNIForThread(),
|
||||||
|
mSurface->wrappedObject());
|
||||||
|
MOZ_ASSERT(mNativeWindow, "Failed to create native window from surface");
|
||||||
|
|
||||||
|
mID = ++sNextID;
|
||||||
|
sInstances.insert(std::pair<int, AndroidSurfaceTexture*>(mID, this));
|
||||||
|
|
||||||
mInitialized = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject CreateSurfaceTexture(GLuint aTexture)
|
AndroidSurfaceTexture::AndroidSurfaceTexture()
|
||||||
|
: mTexture(0)
|
||||||
|
, mSurfaceTexture(nullptr)
|
||||||
|
, mSurface(nullptr)
|
||||||
|
, mMonitor("AndroidSurfaceTexture::mContextMonitor")
|
||||||
|
, mAttachedContext(nullptr)
|
||||||
{
|
{
|
||||||
if (!EnsureInitialized())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
|
|
||||||
return env->NewGlobalRef(env->NewObject(jSurfaceTextureClass, jSurfaceTexture_Ctor, (int) aTexture));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject CreateSurface(jobject aSurfaceTexture)
|
AndroidSurfaceTexture::~AndroidSurfaceTexture()
|
||||||
{
|
{
|
||||||
if (!EnsureInitialized())
|
sInstances.erase(mID);
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
mFrameAvailableCallback = nullptr;
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
return env->NewGlobalRef(env->NewObject(jSurfaceClass, jSurface_Ctor, aSurfaceTexture));
|
if (mSurfaceTexture) {
|
||||||
|
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture->wrappedObject());
|
||||||
|
mSurfaceTexture = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseSurfaceTexture(jobject aSurfaceTexture)
|
void
|
||||||
|
AndroidSurfaceTexture::UpdateTexImage()
|
||||||
{
|
{
|
||||||
JNIEnv* env = GetJNIForThread();
|
mSurfaceTexture->UpdateTexImage();
|
||||||
|
|
||||||
env->DeleteGlobalRef(aSurfaceTexture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTexImage(jobject aSurfaceTexture)
|
void
|
||||||
{
|
AndroidSurfaceTexture::GetTransformMatrix(gfx::Matrix4x4& aMatrix)
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_updateTexImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetTransformMatrix(jobject aSurfaceTexture, gfx::Matrix4x4& aMatrix)
|
|
||||||
{
|
{
|
||||||
JNIEnv* env = GetJNIForThread();
|
JNIEnv* env = GetJNIForThread();
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
|
|
||||||
jfloatArray jarray = env->NewFloatArray(16);
|
jfloatArray jarray = env->NewFloatArray(16);
|
||||||
env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_getTransformMatrix, jarray);
|
mSurfaceTexture->GetTransformMatrix(jarray);
|
||||||
|
|
||||||
jfloat* array = env->GetFloatArrayElements(jarray, nullptr);
|
jfloat* array = env->GetFloatArrayElements(jarray, nullptr);
|
||||||
|
|
||||||
@ -149,240 +223,15 @@ public:
|
|||||||
aMatrix._44 = array[15];
|
aMatrix._44 = array[15];
|
||||||
|
|
||||||
env->ReleaseFloatArrayElements(jarray, array, 0);
|
env->ReleaseFloatArrayElements(jarray, array, 0);
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetDefaultBufferSize(jobject aSurfaceTexture, int32_t width, int32_t height)
|
|
||||||
{
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_setDefaultBufferSize, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachToGLContext(jobject aSurfaceTexture, int32_t texName)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(jSurfaceTexture_attachToGLContext);
|
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_attachToGLContext, texName);
|
|
||||||
if (env->ExceptionCheck()) {
|
|
||||||
env->ExceptionDescribe();
|
|
||||||
env->ExceptionClear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DetachFromGLContext(jobject aSurfaceTexture)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(jSurfaceTexture_detachFromGLContext);
|
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_detachFromGLContext);
|
|
||||||
if (env->ExceptionCheck()) {
|
|
||||||
env->ExceptionDescribe();
|
|
||||||
env->ExceptionClear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool mInitialized;
|
|
||||||
|
|
||||||
jclass jSurfaceTextureClass;
|
|
||||||
jmethodID jSurfaceTexture_Ctor;
|
|
||||||
jmethodID jSurfaceTexture_updateTexImage;
|
|
||||||
jmethodID jSurfaceTexture_getTransformMatrix;
|
|
||||||
jmethodID jSurfaceTexture_setDefaultBufferSize;
|
|
||||||
|
|
||||||
jmethodID jSurfaceTexture_attachToGLContext;
|
|
||||||
jmethodID jSurfaceTexture_detachFromGLContext;
|
|
||||||
|
|
||||||
jclass jSurfaceClass;
|
|
||||||
jmethodID jSurface_Ctor;
|
|
||||||
|
|
||||||
} sJNIFunctions;
|
|
||||||
|
|
||||||
AndroidSurfaceTexture*
|
|
||||||
AndroidSurfaceTexture::Create()
|
|
||||||
{
|
|
||||||
return Create(nullptr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidSurfaceTexture*
|
|
||||||
AndroidSurfaceTexture::Create(GLContext* aContext, GLuint aTexture)
|
|
||||||
{
|
|
||||||
if (!IsSTSupported()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidSurfaceTexture* st = new AndroidSurfaceTexture();
|
|
||||||
if (!st->Init(aContext, aTexture)) {
|
|
||||||
printf_stderr("Failed to initialize AndroidSurfaceTexture");
|
|
||||||
delete st;
|
|
||||||
st = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return st;
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidSurfaceTexture*
|
|
||||||
AndroidSurfaceTexture::Find(int id)
|
|
||||||
{
|
|
||||||
std::map<int, AndroidSurfaceTexture*>::iterator it;
|
|
||||||
|
|
||||||
it = sInstances.find(id);
|
|
||||||
if (it == sInstances.end())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidSurfaceTexture::Check()
|
|
||||||
{
|
|
||||||
return sJNIFunctions.EnsureInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidSurfaceTexture::Attach(GLContext* aContext, PRIntervalTime aTimeout)
|
|
||||||
{
|
|
||||||
MonitorAutoLock lock(mMonitor);
|
|
||||||
|
|
||||||
if (mAttachedContext == aContext) {
|
|
||||||
NS_WARNING("Tried to attach same GLContext to AndroidSurfaceTexture");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsDetachSupported()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (mAttachedContext) {
|
|
||||||
// Wait until it's detached (or we time out)
|
|
||||||
if (NS_FAILED(lock.Wait(aTimeout))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(aContext->IsOwningThreadCurrent(), "Trying to attach GLContext from different thread");
|
|
||||||
|
|
||||||
mAttachedContext = aContext;
|
|
||||||
mAttachedContext->MakeCurrent();
|
|
||||||
aContext->fGenTextures(1, &mTexture);
|
|
||||||
|
|
||||||
sJNIFunctions.AttachToGLContext(mSurfaceTexture, mTexture);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidSurfaceTexture::Detach()
|
|
||||||
{
|
|
||||||
MonitorAutoLock lock(mMonitor);
|
|
||||||
|
|
||||||
if (!IsDetachSupported() ||
|
|
||||||
!mAttachedContext || !mAttachedContext->IsOwningThreadCurrent()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mAttachedContext->MakeCurrent();
|
|
||||||
|
|
||||||
// This call takes care of deleting the texture
|
|
||||||
sJNIFunctions.DetachFromGLContext(mSurfaceTexture);
|
|
||||||
|
|
||||||
mTexture = 0;
|
|
||||||
mAttachedContext = nullptr;
|
|
||||||
lock.NotifyAll();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
|
|
||||||
{
|
|
||||||
if (!aTexture && !IsDetachSupported()) {
|
|
||||||
// We have no texture and cannot initialize detached, bail out
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sJNIFunctions.EnsureInitialized())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
mSurfaceTexture = sJNIFunctions.CreateSurfaceTexture(aTexture);
|
|
||||||
if (!mSurfaceTexture) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!aTexture) {
|
|
||||||
sJNIFunctions.DetachFromGLContext(mSurfaceTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
mAttachedContext = aContext;
|
|
||||||
|
|
||||||
mSurface = sJNIFunctions.CreateSurface(mSurfaceTexture);
|
|
||||||
if (!mSurface) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mNativeWindow = AndroidNativeWindow::CreateFromSurface(env, mSurface);
|
|
||||||
|
|
||||||
mID = ++sNextID;
|
|
||||||
sInstances.insert(std::pair<int, AndroidSurfaceTexture*>(mID, this));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidSurfaceTexture::AndroidSurfaceTexture()
|
|
||||||
: mTexture(0)
|
|
||||||
, mSurfaceTexture(nullptr)
|
|
||||||
, mSurface(nullptr)
|
|
||||||
, mMonitor("AndroidSurfaceTexture::mContextMonitor")
|
|
||||||
, mAttachedContext(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidSurfaceTexture::~AndroidSurfaceTexture()
|
|
||||||
{
|
|
||||||
sInstances.erase(mID);
|
|
||||||
|
|
||||||
mFrameAvailableCallback = nullptr;
|
|
||||||
|
|
||||||
JNIEnv* env = GetJNIForThread();
|
|
||||||
|
|
||||||
if (mSurfaceTexture) {
|
|
||||||
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
|
||||||
|
|
||||||
env->DeleteGlobalRef(mSurfaceTexture);
|
|
||||||
mSurfaceTexture = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mSurface) {
|
|
||||||
env->DeleteGlobalRef(mSurface);
|
|
||||||
mSurface = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidSurfaceTexture::UpdateTexImage()
|
|
||||||
{
|
|
||||||
sJNIFunctions.UpdateTexImage(mSurfaceTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidSurfaceTexture::GetTransformMatrix(gfx::Matrix4x4& aMatrix)
|
|
||||||
{
|
|
||||||
return sJNIFunctions.GetTransformMatrix(mSurfaceTexture, aMatrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
|
AndroidSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
|
||||||
{
|
{
|
||||||
if (aRunnable) {
|
if (aRunnable) {
|
||||||
GeckoAppShell::RegisterSurfaceTextureFrameListener(mSurfaceTexture, mID);
|
GeckoAppShell::RegisterSurfaceTextureFrameListener(mSurfaceTexture->wrappedObject(), mID);
|
||||||
} else {
|
} else {
|
||||||
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture->wrappedObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrameAvailableCallback = aRunnable;
|
mFrameAvailableCallback = aRunnable;
|
||||||
@ -391,7 +240,7 @@ AndroidSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
|
|||||||
void
|
void
|
||||||
AndroidSurfaceTexture::SetDefaultSize(mozilla::gfx::IntSize size)
|
AndroidSurfaceTexture::SetDefaultSize(mozilla::gfx::IntSize size)
|
||||||
{
|
{
|
||||||
sJNIFunctions.SetDefaultBufferSize(mSurfaceTexture, size.width, size.height);
|
mSurfaceTexture->SetDefaultBufferSize(size.width, size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
#include "mozilla/Monitor.h"
|
#include "mozilla/Monitor.h"
|
||||||
|
|
||||||
|
#include "SurfaceTexture.h"
|
||||||
#include "AndroidNativeWindow.h"
|
#include "AndroidNativeWindow.h"
|
||||||
|
|
||||||
class gfxASurface;
|
class gfxASurface;
|
||||||
@ -42,30 +43,26 @@ public:
|
|||||||
|
|
||||||
// The SurfaceTexture is created in an attached state. This method requires
|
// The SurfaceTexture is created in an attached state. This method requires
|
||||||
// Android Ice Cream Sandwich.
|
// Android Ice Cream Sandwich.
|
||||||
static AndroidSurfaceTexture* Create(GLContext* aGLContext, GLuint aTexture);
|
static TemporaryRef<AndroidSurfaceTexture> Create(GLContext* aGLContext, GLuint aTexture);
|
||||||
|
|
||||||
// Here the SurfaceTexture will be created in a detached state. You must call
|
// Here the SurfaceTexture will be created in a detached state. You must call
|
||||||
// Attach() with the GLContext you wish to composite with. It must be done
|
// Attach() with the GLContext you wish to composite with. It must be done
|
||||||
// on the thread where that GLContext is current. This method requires
|
// on the thread where that GLContext is current. This method requires
|
||||||
// Android Jelly Bean.
|
// Android Jelly Bean.
|
||||||
static AndroidSurfaceTexture* Create();
|
static TemporaryRef<AndroidSurfaceTexture> Create();
|
||||||
|
|
||||||
static AndroidSurfaceTexture* Find(int id);
|
static AndroidSurfaceTexture* Find(int id);
|
||||||
|
|
||||||
// Returns with reasonable certainty whether or not we'll
|
|
||||||
// be able to create and use a SurfaceTexture
|
|
||||||
static bool Check();
|
|
||||||
|
|
||||||
// If we are on Jelly Bean, the SurfaceTexture can be detached and reattached
|
// If we are on Jelly Bean, the SurfaceTexture can be detached and reattached
|
||||||
// to allow consumption from different GLContexts. It is recommended to only
|
// to allow consumption from different GLContexts. It is recommended to only
|
||||||
// attach while you are consuming in order to allow this.
|
// attach while you are consuming in order to allow this.
|
||||||
//
|
//
|
||||||
// Only one GLContext may be attached at any given time. If another is already
|
// Only one GLContext may be attached at any given time. If another is already
|
||||||
// attached, we try to wait for it to become detached.
|
// attached, we try to wait for it to become detached.
|
||||||
bool Attach(GLContext* aContext, PRIntervalTime aTiemout = PR_INTERVAL_NO_TIMEOUT);
|
nsresult Attach(GLContext* aContext, PRIntervalTime aTiemout = PR_INTERVAL_NO_TIMEOUT);
|
||||||
|
|
||||||
// This is a noop on ICS, and will always fail
|
// This is a noop on ICS, and will always fail
|
||||||
bool Detach();
|
nsresult Detach();
|
||||||
|
|
||||||
GLContext* GetAttachedContext() { return mAttachedContext; }
|
GLContext* GetAttachedContext() { return mAttachedContext; }
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ public:
|
|||||||
// This attaches the updated data to the TEXTURE_EXTERNAL target
|
// This attaches the updated data to the TEXTURE_EXTERNAL target
|
||||||
void UpdateTexImage();
|
void UpdateTexImage();
|
||||||
|
|
||||||
bool GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix);
|
void GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix);
|
||||||
int ID() { return mID; }
|
int ID() { return mID; }
|
||||||
|
|
||||||
void SetDefaultSize(mozilla::gfx::IntSize size);
|
void SetDefaultSize(mozilla::gfx::IntSize size);
|
||||||
@ -90,7 +87,7 @@ public:
|
|||||||
void NotifyFrameAvailable();
|
void NotifyFrameAvailable();
|
||||||
|
|
||||||
GLuint Texture() { return mTexture; }
|
GLuint Texture() { return mTexture; }
|
||||||
jobject JavaSurface() { return mSurface; }
|
jobject JavaSurface() { return mSurface->wrappedObject(); }
|
||||||
private:
|
private:
|
||||||
AndroidSurfaceTexture();
|
AndroidSurfaceTexture();
|
||||||
~AndroidSurfaceTexture();
|
~AndroidSurfaceTexture();
|
||||||
@ -98,8 +95,8 @@ private:
|
|||||||
bool Init(GLContext* aContext, GLuint aTexture);
|
bool Init(GLContext* aContext, GLuint aTexture);
|
||||||
|
|
||||||
GLuint mTexture;
|
GLuint mTexture;
|
||||||
jobject mSurfaceTexture;
|
nsAutoPtr<mozilla::widget::android::sdk::SurfaceTexture> mSurfaceTexture;
|
||||||
jobject mSurface;
|
nsAutoPtr<mozilla::widget::android::sdk::Surface> mSurface;
|
||||||
|
|
||||||
Monitor mMonitor;
|
Monitor mMonitor;
|
||||||
GLContext* mAttachedContext;
|
GLContext* mAttachedContext;
|
||||||
|
@ -728,7 +728,7 @@ GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
|
|||||||
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
|
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
|
||||||
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
|
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
if (!surfaceTexture->Attach(mGL)) {
|
if (NS_FAILED(surfaceTexture->Attach(mGL))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,9 +534,7 @@ SurfaceTextureHost::Lock()
|
|||||||
mSize);
|
mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSurfTex->Attach(gl());
|
return NS_SUCCEEDED(mSurfTex->Attach(gl()));
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -41,7 +41,9 @@
|
|||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsIScriptError.h"
|
#include "nsIScriptError.h"
|
||||||
#include "nsIHttpChannel.h"
|
#include "nsIHttpChannel.h"
|
||||||
#include "GeneratedSDKWrappers.h"
|
|
||||||
|
#include "MediaCodec.h"
|
||||||
|
#include "SurfaceTexture.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::widget::android;
|
using namespace mozilla::widget::android;
|
||||||
@ -222,8 +224,11 @@ AndroidBridge::Init(JNIEnv *jEnv)
|
|||||||
InitAndroidJavaWrappers(jEnv);
|
InitAndroidJavaWrappers(jEnv);
|
||||||
|
|
||||||
if (mAPIVersion >= 16 /* Jelly Bean */) {
|
if (mAPIVersion >= 16 /* Jelly Bean */) {
|
||||||
// We only use this for MediaCodec right now
|
sdk::InitMediaCodecStubs(jEnv);
|
||||||
InitSDKStubs(jEnv);
|
}
|
||||||
|
|
||||||
|
if (mAPIVersion >= 14 /* ICS */) {
|
||||||
|
sdk::InitSurfaceTextureStubs(jEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// jEnv should NOT be cached here by anything -- the jEnv here
|
// jEnv should NOT be cached here by anything -- the jEnv here
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "mozilla/BasicEvents.h"
|
#include "mozilla/BasicEvents.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "mozilla/TouchEvents.h"
|
#include "mozilla/TouchEvents.h"
|
||||||
#include "GeneratedSDKWrappers.h"
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,335 +0,0 @@
|
|||||||
// GENERATED CODE
|
|
||||||
|
|
||||||
// NOTE: This code has been doctored. The JarClassProcessor is still a work in progress,
|
|
||||||
// and so additions and deletions have been made to make this file valid.
|
|
||||||
|
|
||||||
// Generated by the Java program at /build/jarClassProcessors at compile time from
|
|
||||||
// a given set of jars and a set of requested methods. To update, change the annotations
|
|
||||||
// on the corresponding Java methods and rerun the build. Manually updating this file
|
|
||||||
// will cause your build to fail.
|
|
||||||
|
|
||||||
#ifndef GeneratedSDKWrappers_h__
|
|
||||||
#define GeneratedSDKWrappers_h__
|
|
||||||
|
|
||||||
#include "nsXPCOMStrings.h"
|
|
||||||
#include "AndroidJavaWrappers.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace widget {
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
#define MEDIACODEC_EXCEPTION_INDEX -255
|
|
||||||
|
|
||||||
void InitSDKStubs(JNIEnv *jEnv);
|
|
||||||
|
|
||||||
class MediaCodec : public AutoGlobalWrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitStubs(JNIEnv *jEnv);
|
|
||||||
static MediaCodec* Wrap(jobject obj);
|
|
||||||
MediaCodec(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
|
||||||
bool Configure(jobject a0, jobject a1, jobject a2, int32_t a3);
|
|
||||||
static jobject CreateByCodecName(const nsAString& a0);
|
|
||||||
static jobject CreateDecoderByType(const nsAString& a0);
|
|
||||||
static jobject CreateEncoderByType(const nsAString& a0);
|
|
||||||
int32_t DequeueInputBuffer(int64_t a0);
|
|
||||||
int32_t DequeueOutputBuffer(jobject a0, int64_t a1);
|
|
||||||
void Finalize();
|
|
||||||
void Flush();
|
|
||||||
jobjectArray GetInputBuffers();
|
|
||||||
jobjectArray GetOutputBuffers();
|
|
||||||
jobject GetOutputFormat();
|
|
||||||
void QueueInputBuffer(int32_t a0, int32_t a1, int32_t a2, int64_t a3, int32_t a4);
|
|
||||||
void QueueSecureInputBuffer(int32_t a0, int32_t a1, jobject a2, int64_t a3, int32_t a4);
|
|
||||||
void Release();
|
|
||||||
void ReleaseOutputBuffer(int32_t a0, bool a1);
|
|
||||||
void SetVideoScalingMode(int32_t a0);
|
|
||||||
bool Start();
|
|
||||||
void Stop();
|
|
||||||
static int32_t getBUFFER_FLAG_CODEC_CONFIG();
|
|
||||||
static int32_t getBUFFER_FLAG_END_OF_STREAM();
|
|
||||||
static int32_t getBUFFER_FLAG_SYNC_FRAME();
|
|
||||||
static int32_t getCONFIGURE_FLAG_ENCODE();
|
|
||||||
static int32_t getCRYPTO_MODE_AES_CTR();
|
|
||||||
static int32_t getCRYPTO_MODE_UNENCRYPTED();
|
|
||||||
static int32_t getINFO_OUTPUT_BUFFERS_CHANGED();
|
|
||||||
static int32_t getINFO_OUTPUT_FORMAT_CHANGED();
|
|
||||||
static int32_t getINFO_TRY_AGAIN_LATER();
|
|
||||||
static int32_t getVIDEO_SCALING_MODE_SCALE_TO_FIT();
|
|
||||||
static int32_t getVIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING();
|
|
||||||
MediaCodec() : AutoGlobalWrappedJavaObject() {};
|
|
||||||
protected:
|
|
||||||
static jclass mMediaCodecClass;
|
|
||||||
static jmethodID jConfigure;
|
|
||||||
static jmethodID jCreateByCodecName;
|
|
||||||
static jmethodID jCreateDecoderByType;
|
|
||||||
static jmethodID jCreateEncoderByType;
|
|
||||||
static jmethodID jDequeueInputBuffer;
|
|
||||||
static jmethodID jDequeueOutputBuffer;
|
|
||||||
static jmethodID jFinalize;
|
|
||||||
static jmethodID jFlush;
|
|
||||||
static jmethodID jGetInputBuffers;
|
|
||||||
static jmethodID jGetOutputBuffers;
|
|
||||||
static jmethodID jGetOutputFormat;
|
|
||||||
static jmethodID jQueueInputBuffer;
|
|
||||||
static jmethodID jQueueSecureInputBuffer;
|
|
||||||
static jmethodID jRelease;
|
|
||||||
static jmethodID jReleaseOutputBuffer;
|
|
||||||
static jmethodID jSetVideoScalingMode;
|
|
||||||
static jmethodID jStart;
|
|
||||||
static jmethodID jStop;
|
|
||||||
static jfieldID jBUFFER_FLAG_CODEC_CONFIG;
|
|
||||||
static jfieldID jBUFFER_FLAG_END_OF_STREAM;
|
|
||||||
static jfieldID jBUFFER_FLAG_SYNC_FRAME;
|
|
||||||
static jfieldID jCONFIGURE_FLAG_ENCODE;
|
|
||||||
static jfieldID jCRYPTO_MODE_AES_CTR;
|
|
||||||
static jfieldID jCRYPTO_MODE_UNENCRYPTED;
|
|
||||||
static jfieldID jINFO_OUTPUT_BUFFERS_CHANGED;
|
|
||||||
static jfieldID jINFO_OUTPUT_FORMAT_CHANGED;
|
|
||||||
static jfieldID jINFO_TRY_AGAIN_LATER;
|
|
||||||
static jfieldID jVIDEO_SCALING_MODE_SCALE_TO_FIT;
|
|
||||||
static jfieldID jVIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MediaFormat : public AutoGlobalWrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitStubs(JNIEnv *jEnv);
|
|
||||||
static MediaFormat* Wrap(jobject obj);
|
|
||||||
MediaFormat(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
|
||||||
MediaFormat();
|
|
||||||
bool ContainsKey(const nsAString& a0);
|
|
||||||
static jobject CreateAudioFormat(const nsAString& a0, int32_t a1, int32_t a2);
|
|
||||||
static jobject CreateVideoFormat(const nsAString& a0, int32_t a1, int32_t a2);
|
|
||||||
jobject GetByteBuffer(const nsAString& a0);
|
|
||||||
jfloat GetFloat(const nsAString& a0);
|
|
||||||
int32_t GetInteger(const nsAString& a0);
|
|
||||||
int64_t GetLong(const nsAString& a0);
|
|
||||||
jstring GetString(const nsAString& a0);
|
|
||||||
void SetByteBuffer(const nsAString& a0, jobject a1);
|
|
||||||
void SetFloat(const nsAString& a0, jfloat a1);
|
|
||||||
void SetInteger(const nsAString& a0, int32_t a1);
|
|
||||||
void SetLong(const nsAString& a0, int64_t a1);
|
|
||||||
void SetString(const nsAString& a0, const nsAString& a1);
|
|
||||||
jstring ToString();
|
|
||||||
static jstring getKEY_AAC_PROFILE();
|
|
||||||
static jstring getKEY_BIT_RATE();
|
|
||||||
static jstring getKEY_CHANNEL_COUNT();
|
|
||||||
static jstring getKEY_CHANNEL_MASK();
|
|
||||||
static jstring getKEY_COLOR_FORMAT();
|
|
||||||
static jstring getKEY_DURATION();
|
|
||||||
static jstring getKEY_FLAC_COMPRESSION_LEVEL();
|
|
||||||
static jstring getKEY_FRAME_RATE();
|
|
||||||
static jstring getKEY_HEIGHT();
|
|
||||||
static jstring getKEY_IS_ADTS();
|
|
||||||
static jstring getKEY_I_FRAME_INTERVAL();
|
|
||||||
static jstring getKEY_MAX_INPUT_SIZE();
|
|
||||||
static jstring getKEY_MIME();
|
|
||||||
static jstring getKEY_SAMPLE_RATE();
|
|
||||||
static jstring getKEY_WIDTH();
|
|
||||||
protected:
|
|
||||||
static jclass mMediaFormatClass;
|
|
||||||
static jmethodID jMediaFormat;
|
|
||||||
static jmethodID jContainsKey;
|
|
||||||
static jmethodID jCreateAudioFormat;
|
|
||||||
static jmethodID jCreateVideoFormat;
|
|
||||||
static jmethodID jGetByteBuffer;
|
|
||||||
static jmethodID jGetFloat;
|
|
||||||
static jmethodID jGetInteger;
|
|
||||||
static jmethodID jGetLong;
|
|
||||||
static jmethodID jGetString;
|
|
||||||
static jmethodID jSetByteBuffer;
|
|
||||||
static jmethodID jSetFloat;
|
|
||||||
static jmethodID jSetInteger;
|
|
||||||
static jmethodID jSetLong;
|
|
||||||
static jmethodID jSetString;
|
|
||||||
static jmethodID jToString;
|
|
||||||
static jfieldID jKEY_AAC_PROFILE;
|
|
||||||
static jfieldID jKEY_BIT_RATE;
|
|
||||||
static jfieldID jKEY_CHANNEL_COUNT;
|
|
||||||
static jfieldID jKEY_CHANNEL_MASK;
|
|
||||||
static jfieldID jKEY_COLOR_FORMAT;
|
|
||||||
static jfieldID jKEY_DURATION;
|
|
||||||
static jfieldID jKEY_FLAC_COMPRESSION_LEVEL;
|
|
||||||
static jfieldID jKEY_FRAME_RATE;
|
|
||||||
static jfieldID jKEY_HEIGHT;
|
|
||||||
static jfieldID jKEY_IS_ADTS;
|
|
||||||
static jfieldID jKEY_I_FRAME_INTERVAL;
|
|
||||||
static jfieldID jKEY_MAX_INPUT_SIZE;
|
|
||||||
static jfieldID jKEY_MIME;
|
|
||||||
static jfieldID jKEY_SAMPLE_RATE;
|
|
||||||
static jfieldID jKEY_WIDTH;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ByteBuffer : public AutoGlobalWrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitStubs(JNIEnv *jEnv);
|
|
||||||
static ByteBuffer* Wrap(jobject obj);
|
|
||||||
ByteBuffer(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
|
||||||
int8_t _get(int32_t a0);
|
|
||||||
void _put(int32_t a0, int8_t a1);
|
|
||||||
static jobject Allocate(int32_t a0);
|
|
||||||
static jobject AllocateDirect(int32_t a0);
|
|
||||||
jobject Array();
|
|
||||||
jbyteArray Array1();
|
|
||||||
int32_t ArrayOffset();
|
|
||||||
jstring AsCharBuffer();
|
|
||||||
jobject AsDoubleBuffer();
|
|
||||||
jobject AsFloatBuffer();
|
|
||||||
jobject AsIntBuffer();
|
|
||||||
jobject AsLongBuffer();
|
|
||||||
jobject AsReadOnlyBuffer();
|
|
||||||
jobject AsShortBuffer();
|
|
||||||
jobject Compact();
|
|
||||||
int32_t CompareTo(jobject a0);
|
|
||||||
int32_t CompareTo1(jobject a0);
|
|
||||||
jobject Duplicate();
|
|
||||||
bool Equals(jobject a0);
|
|
||||||
int8_t Get();
|
|
||||||
int8_t Get1(int32_t a0);
|
|
||||||
jobject Get1(jbyteArray a0);
|
|
||||||
jobject Get1(jbyteArray a0, int32_t a1, int32_t a2);
|
|
||||||
uint16_t GetChar();
|
|
||||||
uint16_t GetChar1(int32_t a0);
|
|
||||||
jdouble GetDouble();
|
|
||||||
jdouble GetDouble1(int32_t a0);
|
|
||||||
jfloat GetFloat();
|
|
||||||
jfloat GetFloat1(int32_t a0);
|
|
||||||
int32_t GetInt();
|
|
||||||
int32_t GetInt1(int32_t a0);
|
|
||||||
int64_t GetLong();
|
|
||||||
int64_t GetLong1(int32_t a0);
|
|
||||||
int16_t GetShort();
|
|
||||||
int16_t GetShort1(int32_t a0);
|
|
||||||
bool HasArray();
|
|
||||||
int32_t HashCode();
|
|
||||||
bool IsDirect();
|
|
||||||
jobject Order();
|
|
||||||
jobject Order1(jobject a0);
|
|
||||||
jobject Put(int8_t a0);
|
|
||||||
jobject Put1(int32_t a0, int8_t a1);
|
|
||||||
jobject Put1(jobject a0);
|
|
||||||
jobject Put1(jbyteArray a0);
|
|
||||||
jobject Put1(jbyteArray a0, int32_t a1, int32_t a2);
|
|
||||||
jobject PutChar(uint16_t a0);
|
|
||||||
jobject PutChar1(int32_t a0, uint16_t a1);
|
|
||||||
jobject PutDouble(jdouble a0);
|
|
||||||
jobject PutDouble1(int32_t a0, jdouble a1);
|
|
||||||
jobject PutFloat(jfloat a0);
|
|
||||||
jobject PutFloat1(int32_t a0, jfloat a1);
|
|
||||||
jobject PutInt(int32_t a0);
|
|
||||||
jobject PutInt1(int32_t a0, int32_t a1);
|
|
||||||
jobject PutLong(int32_t a0, int64_t a1);
|
|
||||||
jobject PutLong1(int64_t a0);
|
|
||||||
jobject PutShort(int32_t a0, int16_t a1);
|
|
||||||
jobject PutShort1(int16_t a0);
|
|
||||||
jobject Slice();
|
|
||||||
jstring ToString();
|
|
||||||
static jobject Wrap1(jbyteArray a0);
|
|
||||||
static jobject Wrap2(jbyteArray a0, int32_t a1, int32_t a2);
|
|
||||||
bool getBigEndian();
|
|
||||||
void setBigEndian(bool a0);
|
|
||||||
jbyteArray getHb();
|
|
||||||
bool getIsReadOnly();
|
|
||||||
void setIsReadOnly(bool a0);
|
|
||||||
bool getNativeByteOrder();
|
|
||||||
void setNativeByteOrder(bool a0);
|
|
||||||
int32_t getOffset();
|
|
||||||
ByteBuffer() : AutoGlobalWrappedJavaObject() {};
|
|
||||||
protected:
|
|
||||||
static jclass mByteBufferClass;
|
|
||||||
static jmethodID j_get;
|
|
||||||
static jmethodID j_put;
|
|
||||||
static jmethodID jAllocate;
|
|
||||||
static jmethodID jAllocateDirect;
|
|
||||||
static jmethodID jArray;
|
|
||||||
static jmethodID jArray1;
|
|
||||||
static jmethodID jArrayOffset;
|
|
||||||
static jmethodID jAsCharBuffer;
|
|
||||||
static jmethodID jAsDoubleBuffer;
|
|
||||||
static jmethodID jAsFloatBuffer;
|
|
||||||
static jmethodID jAsIntBuffer;
|
|
||||||
static jmethodID jAsLongBuffer;
|
|
||||||
static jmethodID jAsReadOnlyBuffer;
|
|
||||||
static jmethodID jAsShortBuffer;
|
|
||||||
static jmethodID jCompact;
|
|
||||||
static jmethodID jCompareTo;
|
|
||||||
static jmethodID jCompareTo1;
|
|
||||||
static jmethodID jDuplicate;
|
|
||||||
static jmethodID jEquals;
|
|
||||||
static jmethodID jGet;
|
|
||||||
static jmethodID jGet1;
|
|
||||||
static jmethodID jGet10;
|
|
||||||
static jmethodID jGet11;
|
|
||||||
static jmethodID jGetChar;
|
|
||||||
static jmethodID jGetChar1;
|
|
||||||
static jmethodID jGetDouble;
|
|
||||||
static jmethodID jGetDouble1;
|
|
||||||
static jmethodID jGetFloat;
|
|
||||||
static jmethodID jGetFloat1;
|
|
||||||
static jmethodID jGetInt;
|
|
||||||
static jmethodID jGetInt1;
|
|
||||||
static jmethodID jGetLong;
|
|
||||||
static jmethodID jGetLong1;
|
|
||||||
static jmethodID jGetShort;
|
|
||||||
static jmethodID jGetShort1;
|
|
||||||
static jmethodID jHasArray;
|
|
||||||
static jmethodID jHashCode;
|
|
||||||
static jmethodID jIsDirect;
|
|
||||||
static jmethodID jOrder;
|
|
||||||
static jmethodID jOrder1;
|
|
||||||
static jmethodID jPut;
|
|
||||||
static jmethodID jPut1;
|
|
||||||
static jmethodID jPut12;
|
|
||||||
static jmethodID jPut13;
|
|
||||||
static jmethodID jPut14;
|
|
||||||
static jmethodID jPutChar;
|
|
||||||
static jmethodID jPutChar1;
|
|
||||||
static jmethodID jPutDouble;
|
|
||||||
static jmethodID jPutDouble1;
|
|
||||||
static jmethodID jPutFloat;
|
|
||||||
static jmethodID jPutFloat1;
|
|
||||||
static jmethodID jPutInt;
|
|
||||||
static jmethodID jPutInt1;
|
|
||||||
static jmethodID jPutLong;
|
|
||||||
static jmethodID jPutLong1;
|
|
||||||
static jmethodID jPutShort;
|
|
||||||
static jmethodID jPutShort1;
|
|
||||||
static jmethodID jSlice;
|
|
||||||
static jmethodID jToString;
|
|
||||||
static jmethodID jWrap;
|
|
||||||
static jmethodID jWrap1;
|
|
||||||
static jfieldID jBigEndian;
|
|
||||||
static jfieldID jHb;
|
|
||||||
static jfieldID jIsReadOnly;
|
|
||||||
static jfieldID jNativeByteOrder;
|
|
||||||
static jfieldID jOffset;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BufferInfo : public AutoGlobalWrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitStubs(JNIEnv *jEnv);
|
|
||||||
static BufferInfo* Wrap(jobject obj);
|
|
||||||
BufferInfo(jobject obj, JNIEnv* env) : AutoGlobalWrappedJavaObject(obj, env) {};
|
|
||||||
BufferInfo();
|
|
||||||
void Set(int32_t a0, int32_t a1, int64_t a2, int32_t a3);
|
|
||||||
int32_t getFlags();
|
|
||||||
void setFlags(int32_t a0);
|
|
||||||
int32_t getOffset();
|
|
||||||
void setOffset(int32_t a0);
|
|
||||||
int64_t getPresentationTimeUs();
|
|
||||||
void setPresentationTimeUs(int64_t a0);
|
|
||||||
int32_t getSize();
|
|
||||||
void setSize(int32_t a0);
|
|
||||||
protected:
|
|
||||||
static jclass mBufferInfoClass;
|
|
||||||
static jmethodID jBufferInfo;
|
|
||||||
static jmethodID jSet;
|
|
||||||
static jfieldID jFlags;
|
|
||||||
static jfieldID jOffset;
|
|
||||||
static jfieldID jPresentationTimeUs;
|
|
||||||
static jfieldID jSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* android */
|
|
||||||
} /* widget */
|
|
||||||
} /* mozilla */
|
|
||||||
#endif
|
|
@ -19,7 +19,6 @@ EXPORTS += [
|
|||||||
'AndroidJavaWrappers.h',
|
'AndroidJavaWrappers.h',
|
||||||
'AndroidJNIWrapper.h',
|
'AndroidJNIWrapper.h',
|
||||||
'GeneratedJNIWrappers.h',
|
'GeneratedJNIWrappers.h',
|
||||||
'GeneratedSDKWrappers.h',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
@ -31,7 +30,6 @@ SOURCES += [
|
|||||||
'AndroidJNIWrapper.cpp',
|
'AndroidJNIWrapper.cpp',
|
||||||
'APZCCallbackHandler.cpp',
|
'APZCCallbackHandler.cpp',
|
||||||
'GeneratedJNIWrappers.cpp',
|
'GeneratedJNIWrappers.cpp',
|
||||||
'GeneratedSDKWrappers.cpp',
|
|
||||||
'GfxInfo.cpp',
|
'GfxInfo.cpp',
|
||||||
'NativeJSContainer.cpp',
|
'NativeJSContainer.cpp',
|
||||||
'nsAndroidProtocolHandler.cpp',
|
'nsAndroidProtocolHandler.cpp',
|
||||||
|
Loading…
Reference in New Issue
Block a user