From 0250edfd9c4d453f25a2f9827698ccf87ff5afff Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 17 八月 2017 10:22:18 +0800
Subject: [PATCH] merge home base
---
/dev/null | 125 -----------------------------------------
RtspFace/PL_InterProcessJoint.h | 1
RtspFace/PL_RTSPServer.cpp | 15 ++++-
RtspFace/PL_SensetimeFaceFeatureEmit.h | 6 ++
RtspFace/PL_RTSPServer.h | 2
RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp | 4 +
6 files changed, 24 insertions(+), 129 deletions(-)
diff --git a/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp b/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp
index 226e45a..fa689f0 100644
--- a/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp
+++ b/RtspFace/PL_AndroidMediaCodecDecoder_ndk.cpp
@@ -202,6 +202,10 @@
return false;
}
+ static FILE *pFile = fopen("/data/bb.264", "wb");
+ fwrite(frame->buffer, sizeof(char), frame->buffSize, pFile);
+ fflush(pFile);
+
ssize_t bufidx = AMediaCodec_dequeueInputBuffer(in->codec, 2000);
LOGP(DEBUG, "input buffer bufidx=%zd, inputFrameCount=%d", bufidx, in->inputFrameCount++);
diff --git a/RtspFace/PL_BlockPredictor.cpp b/RtspFace/PL_BlockPredictor.cpp
deleted file mode 100644
index 1695f7d..0000000
--- a/RtspFace/PL_BlockPredictor.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-#include "PL_BlockPredictor.h"
-#include "MaterialBuffer.h"
-#include "logger.h"
-#include "MediaHelper.h"
-
-#include <string.h> // for memcpy
-#include <opencv2/core/mat.hpp>
-#include <opencv2/imgproc.hpp>
-
-struct PL_BlockPredictor_Internal
-{
- uint8_t* buffer;
- size_t buffSize;
-
- PL_BlockPredictor_Config config;
- PipeMaterial pmList[2];
- MB_Frame lastMbfBuffOrigin;
- MB_Frame lastMbfBuffCopy;
-
- bool payError;
-
- PL_BlockPredictor_Internal() :
- buffer(nullptr), buffSize(), config(), pmList(),
- lastMbfBuffOrigin(), lastMbfBuffCopy(),
- payError(true)
- {
- }
-
- ~PL_BlockPredictor_Internal()
- {
- reset();
- }
-
- void reset()
- {
- delete buffer;
- buffer = nullptr;
- buffSize = 0;
-
- PL_BlockPredictor_Config _config;
- config = _config;
-
- PipeMaterial _pm;
- pmList[0] = _pm;
- pmList[1] = _pm;
-
- MB_Frame _lastMbfBuff;
- lastMbfBuffOrigin = _lastMbfBuff;
- lastMbfBuffCopy = _lastMbfBuff;
-
- payError = true;
- }
-};
-
-PipeLineElem* create_PL_BlockPredictor()
-{
- return new PL_BlockPredictor;
-}
-
-PL_BlockPredictor::PL_BlockPredictor() : internal(new PL_BlockPredictor_Internal)
-{
-}
-
-PL_BlockPredictor::~PL_BlockPredictor()
-{
- delete (PL_BlockPredictor_Internal*)internal;
- internal= nullptr;
-}
-
-bool PL_BlockPredictor::init(void* args)
-{
- PL_BlockPredictor_Internal* in = (PL_BlockPredictor_Internal*)internal;
- in->reset();
-
- if (args != nullptr)
- {
- PL_BlockPredictor_Config* config = (PL_BlockPredictor_Config*)args;
- in->config = *config;
- }
-
- return true;
-}
-
-void PL_BlockPredictor::finit()
-{
- PL_BlockPredictor_Internal* in = (PL_BlockPredictor_Internal*)internal;
-
-}
-
-bool PL_BlockPredictor::pay(const PipeMaterial& pm)
-{
- PL_BlockPredictor_Internal* in = (PL_BlockPredictor_Internal*)internal;
- in->payError = true;
- pm.breake(PipeMaterial::PMT_PTR, MB_Frame::MBFT__FIRST, fc_pm_breaker_ptr, _ctx);
- pm.breake(PipeMaterial::PMT_FRAME, MB_Frame::MBFT__FIRST, fc_pm_breaker_frame, _ctx);
-
- //#todo support RGB
-
- return !(in->payError);
-}
-
-bool PL_BlockPredictor::gain(PipeMaterial& pm)
-{
- PL_BlockPredictor_Internal* in = (PL_BlockPredictor_Internal*)internal;
-
- if (in->payError)
- {
- pm.former = this;
- return false;
- }
-
- if (!in->config.copyData)
- {
- pm.type = PipeMaterial::PMT_FRAME;
- pm.buffer = &(in->lastMbfBuffOrigin);
- pm.buffSize = 0;
- }
- else
- {
- in->pmList[0].type = PipeMaterial::PMT_FRAME;
- in->pmList[0].buffer = &(in->lastMbfBuffCopy);
- in->pmList[0].buffSize = 0;
- in->pmList[0].former = this;
-
- in->pmList[1].type = PipeMaterial::PMT_FRAME;
- in->pmList[1].buffer = &(in->lastMbfBuffOrigin);
- in->pmList[1].buffSize = 0;
- in->pmList[1].former = this;
-
- pm.type = PipeMaterial::PMT_PM_LIST;
- pm.buffer = in->pmList;
- pm.buffSize = sizeof(in->pmList) / sizeof(PipeMaterial);
- }
-
- pm.former = this;
- return true;
-}
diff --git a/RtspFace/PL_BlockPredictor.h b/RtspFace/PL_BlockPredictor.h
deleted file mode 100644
index b139971..0000000
--- a/RtspFace/PL_BlockPredictor.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _PL_BlockPredictor_H_
-#define _PL_BlockPredictor_H_
-
-#include "PipeLine.h"
-
-typedef float (plbg_user_score_func_t*)(const PipeMaterial& pm);
-
-struct PL_BlockPredictor_Config
-{
-
- PL_BlockPredictor_Config() :
- copyData(true)
- { }
-};
-
-class PL_BlockPredictor : public PipeLineElem
-{
-public:
- PL_BlockPredictor();
- virtual ~PL_BlockPredictor();
-
- virtual bool init(void* args);
- virtual void finit();
-
- virtual bool pay(const PipeMaterial& pm);
- virtual bool gain(PipeMaterial& pm);
-
-private:
- static bool pay_breaker_MBFT_YUV(const PipeMaterial* pm, void* args);
-
-private:
- void* internal;
-};
-
-PipeLineElem* create_PL_BlockPredictor();
-
-#endif
diff --git a/RtspFace/PL_InterProcessJoint.h b/RtspFace/PL_InterProcessJoint.h
new file mode 100644
index 0000000..79775a9
--- /dev/null
+++ b/RtspFace/PL_InterProcessJoint.h
@@ -0,0 +1 @@
+// split pipeline into two process via network
diff --git a/RtspFace/PL_RTSPServer.cpp b/RtspFace/PL_RTSPServer.cpp
index d3da325..4f140ca 100644
--- a/RtspFace/PL_RTSPServer.cpp
+++ b/RtspFace/PL_RTSPServer.cpp
@@ -96,9 +96,18 @@
ReleaseFrame();
return 0;
}
-
+
+ //static size_t f = 0;
+ //static FILE *pFile = fopen("/data/bb.264", "wb");
+ //fwrite(in.buffer, sizeof(char), in.buffSize, pFile);
+ //if (++f > 400){
+ // fclose(pFile);
+ // exit(0);
+ //}
+
uint8_t* pBuffer = in.buffer;
size_t newBufferSize = in.buffSize;
+
if (in.config.payWithAux)
{
if (newBufferSize <= 4)
@@ -109,7 +118,7 @@
pBuffer += 4;
newBufferSize -= 4;
}
-
+
*FrameBuffer = pBuffer;
*FrameSize = newBufferSize;
@@ -233,7 +242,7 @@
return false;
memcpy(in->buffer, frame->buffer, frame->buffSize);
in->buffSize = frame->buffSize;
-
+
if (in->encoderStub == nullptr)
return false;
diff --git a/RtspFace/PL_RTSPServer.h b/RtspFace/PL_RTSPServer.h
index ea9e154..89e2eca 100644
--- a/RtspFace/PL_RTSPServer.h
+++ b/RtspFace/PL_RTSPServer.h
@@ -1,5 +1,5 @@
#ifndef _PL_RTSPSERVER_H_
-#define _PL_PL_RTSPSERVER_H_
+#define _PL_RTSPSERVER_H_
#include "PipeLine.h"
diff --git a/RtspFace/PL_SensetimeFaceFeatureEmit.h b/RtspFace/PL_SensetimeFaceFeatureEmit.h
new file mode 100644
index 0000000..c312a0c
--- /dev/null
+++ b/RtspFace/PL_SensetimeFaceFeatureEmit.h
@@ -0,0 +1,6 @@
+#ifndef _PL_SENSETIMEFACEFEATUREEMIT_H_
+#define _PL_SENSETIMEFACEFEATUREEMIT_H_
+
+#include "PipeLine.h"
+
+#endif
diff --git a/RtspFace/PL_SocketGainer.cpp b/RtspFace/PL_SocketGainer.cpp
deleted file mode 100644
index 4840338..0000000
--- a/RtspFace/PL_SocketGainer.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-#include "PL_SocketGainer.h"
-#include "MaterialBuffer.h"
-#include "logger.h"
-
-struct PL_SocketGainer_Internal
-{
- uint8_t* buffer;
- size_t buffSize;
- size_t buffSizeMax;
- bool payError;
-
- PipeMaterial::PipeMaterialBufferType lastPmType;
- MB_Frame lastFrame;
- PL_SocketGainer_Config config;
-
- PL_SocketGainer_Internal() :
- buffer(nullptr), buffSize(0), buffSizeMax(0), payError(true),
- lastPmType(PipeMaterial::PMT_NONE), lastFrame(), config()
- {
- }
-
- ~PL_SocketGainer_Internal()
- {
- delete[] buffer;
- buffer = nullptr;
- }
-
- void reset()
- {
- buffSize = 0;
- payError = true;
-
- lastPmType = PipeMaterial::PMT_NONE;
-
- MB_Frame _lastFrame;
- lastFrame = _lastFrame;
-
- PL_SocketGainer_Config _config;
- config = _config;
-
- if (buffer != nullptr)
- {
- delete[] buffer;
- buffer = nullptr;
- buffSizeMax = 0;
- }
- }
-};
-
-PipeLineElem* create_PL_SocketGainer()
-{
- return new PL_SocketGainer;
-}
-
-PL_SocketGainer::PL_SocketGainer() : internal(new PL_SocketGainer_Internal)
-{
-}
-
-PL_SocketGainer::~PL_SocketGainer()
-{
- delete (PL_SocketGainer_Internal*)internal;
- internal= nullptr;
-}
-
-bool PL_SocketGainer::init(void* args)
-{
- PL_SocketGainer_Internal* in = (PL_SocketGainer_Internal*)internal;
- in->reset();
-
- if (args != nullptr)
- {
- PL_SocketGainer_Config* config = (PL_SocketGainer_Config*)args;
- in->config = *config;
- }
-
- if (in->config.toWidth <= 0 || in->config.toHeight <= 0)
- {
- LOG_ERROR << "Config toWidth and toHeight should > 0" << std::endl;
- return false;
- }
-
- return true;
-}
-
-void PL_SocketGainer::finit()
-{
- PL_SocketGainer_Internal* in = (PL_SocketGainer_Internal*)internal;
-
-}
-
-bool PL_SocketGainer::pay(const PipeMaterial& pm)
-{
- PL_SocketGainer_Internal* in = (PL_SocketGainer_Internal*)internal;
-
- in->payError = true;
-
- if (pm.buffer == nullptr)
- return false;
-
- bool ret = false;
-
- in->lastPmType = pm.type;
-
- switch(pm.type)
- {
- case PipeMaterial::PMT_BYTES:
- {
- //if (in->config.defaultBytesType <= 0 ||
- // in->config.defaultBytesWidth <= 0 || in->config.defaultBytesHeight <= 0)
- //{
- // LOG_ERROR << "defaultBytesType/defaultBytesWidth/defaultBytesHeight not set" << std::endl;
- // return false;
- //}
- //
- //ret = image_scale(in, (uint8_t*)pm.buffer, pm.buffSize, (MB_Frame::MBFType)(in->config.defaultBytesType),
- // in->config.defaultBytesWidth, in->config.defaultBytesHeight);
- }
- break;
- case PipeMaterial::PMT_FRAME:
- {
- //MB_Frame* frame = (MB_Frame*)pm.buffer;
- //switch(frame->type)
- //{
- //case MB_Frame::MBFT_YUV420:
- //case MB_Frame::MBFT_BGRA:
- // in->lastFrame = *frame;
- // ret = image_scale(in, (uint8_t*)frame->buffer, frame->buffSize, frame->type,
- // frame->width, frame->height);
- // break;
- //default:
- // LOG_ERROR << "Only support MBFT_YUV420 / MBFT_BGRA" << std::endl;
- // return false;
- //}
- }
- break;
- default:
- LOG_ERROR << "Only support PMT_BYTES / PMT_FRAME" << std::endl;
- return false;
- }
-
- in->payError = !ret;
- return ret;
-}
-
-bool PL_SocketGainer::gain(PipeMaterial& pm)
-{
- PL_SocketGainer_Internal* in = (PL_SocketGainer_Internal*)internal;
-
- PipeMaterial newPm;
- newPm.type = PipeMaterial::PMT_NONE;
- newPm.former = this;
-
- switch(in->lastPmType)
- {
- case PipeMaterial::PMT_BYTES:
- {
- newPm.type = PipeMaterial::PMT_BYTES;
- newPm.buffer = in->buffer;
- newPm.buffSize = in->buffSize;
- }
- break;
- case PipeMaterial::PMT_FRAME:
- {
- newPm.type = PipeMaterial::PMT_FRAME;
- newPm.buffer = &(in->lastFrame);
- newPm.buffSize = 0;
-
- in->lastFrame.buffer = in->buffer;
- in->lastFrame.buffSize = in->buffSize;
- in->lastFrame.width = in->config.toWidth;
- in->lastFrame.height = in->config.toHeight;
- }
- break;
- default:
- LOG_ERROR << "Only support PMT_BYTES / PMT_FRAME" << std::endl;
- }
-
- pm = newPm;
- return !in->payError;
-}
diff --git a/RtspFace/PL_SocketGainer.h b/RtspFace/PL_SocketGainer.h
deleted file mode 100644
index ecad18b..0000000
--- a/RtspFace/PL_SocketGainer.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef _PL_SocketGainer_H_
-#define _PL_SocketGainer_H_
-
-#include "PipeLine.h"
-
-struct PL_SocketGainer_Config
-{
- uint16_t toWidth;
- uint16_t toHeight;
- int filterMode; // libyuv/scale.h/FilterMode
-
- // Used only pm.type==PMT_BYTES
- int defaultBytesType; // MBFT_YUV420 / MBFT_BGRA
- uint16_t defaultBytesWidth;
- uint16_t defaultBytesHeight;
-
- PL_SocketGainer_Config() :
- toWidth(0), toHeight(0), filterMode(0),
- defaultBytesType(0), defaultBytesWidth(0), defaultBytesHeight(0)
- { }
-};
-
-class PL_SocketGainer : public PipeLineElem
-{
-public:
- PL_SocketGainer();
- virtual ~PL_SocketGainer();
-
- virtual bool init(void* args);
- virtual void finit();
-
- virtual bool pay(const PipeMaterial& pm);
- virtual bool gain(PipeMaterial& pm);
-
-private:
- void* internal;
-};
-
-PipeLineElem* create_PL_SocketGainer();
-
-#endif
diff --git a/RtspFace/PL_StaticJpegSource.cpp b/RtspFace/PL_StaticJpegSource.cpp
deleted file mode 100644
index 6ad3382..0000000
--- a/RtspFace/PL_StaticJpegSource.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "PL_StaticJpegSource.h"
-
-extern "C"
-{
- #include <libyuv.h>
-}
-
-struct PL_StaticJpegSource_Internal
-{
- uint8_t buffer[1920*1080*4];
- size_t buffSize;
- size_t buffSizeMax;
-
- bool payError;
-
- PL_StaticJpegSource_Internal() :
- buffSize(0), buffSizeMax(sizeof(buffer)),
- payError(true)
- {
- }
-
- ~PL_StaticJpegSource_Internal()
- {
- }
-
- void reset()
- {
- buffSize = 0;
- payError = true;
- }
-};
-
-PipeLineElem* create_PL_StaticJpegSource()
-{
- return new PL_StaticJpegSource;
-}
-
-PL_StaticJpegSource::PL_StaticJpegSource() : internal(new PL_StaticJpegSource_Internal)
-{
-}
-
-PL_StaticJpegSource::~PL_StaticJpegSource()
-{
- delete (PL_StaticJpegSource_Internal*)internal;
- internal= nullptr;
-}
-
-bool PL_StaticJpegSource::init(void* args)
-{
- PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
- in->reset();
-
- return true;
-}
-
-void PL_StaticJpegSource::finit()
-{
- PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
-
-}
-
-bool PL_StaticJpegSource::pay(const PipeMaterial& pm)
-{
- PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
-
- //in->buffer readly
-
- //static size_t f=0;
- //char fname[50];
- //sprintf(fname, "%u.bgra", ++f);
- //FILE * pFile = fopen (fname,"wb");
- //fwrite (in->buffer , sizeof(char), in->buffSize, pFile);
- //fclose(pFile);
-
- return true;
-}
-
-bool PL_StaticJpegSource::gain(PipeMaterial& pm)
-{
- PL_StaticJpegSource_Internal* in = (PL_StaticJpegSource_Internal*)internal;
-
- pm.buffer = in->buffer;
- pm.buffSize = in->buffSize;
- pm.former = this;
- return true;
-}
diff --git a/RtspFace/PL_StaticJpegSource.h b/RtspFace/PL_StaticJpegSource.h
deleted file mode 100644
index 08aa5b8..0000000
--- a/RtspFace/PL_StaticJpegSource.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _PL_PL_StaticJpegSource_H_
-#define _PL_PL_StaticJpegSource_H_
-
-#include "PipeLine.h"
-
-class PL_StaticJpegSource : public PipeLineElem
-{
-public:
- PL_StaticJpegSource();
- virtual ~PL_StaticJpegSource();
-
- virtual bool init(void* args);
- virtual void finit();
-
- virtual bool pay(const PipeMaterial& pm);
- virtual bool gain(PipeMaterial& pm);
-
-private:
- void* internal;
-};
-
-PipeLineElem* create_PL_StaticJpegSource();
-
-#endif
diff --git a/RtspFace/PL_V4L2Sink.h b/RtspFace/PL_V4L2Sink.h
deleted file mode 100644
index cef797d..0000000
--- a/RtspFace/PL_V4L2Sink.h
+++ /dev/null
@@ -1,2 +0,0 @@
-// use https://github.com/mpromonet/libv4l2cpp
-
diff --git a/RtspFace/PL_V4L2Source.cpp b/RtspFace/PL_V4L2Source.cpp
deleted file mode 100644
index 0d91709..0000000
--- a/RtspFace/PL_V4L2Source.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-#include "PL_V4L2Source.h"
-#include "MaterialBuffer.h"
-#include "logger.h"
-#include "MediaHelper.h"
-
-#include <linux/videodev2.h>
-#include <V4l2Device.h>
-#include <V4l2Capture.h>
-#include <V4l2Output.h>
-
-#include <libyuv.h>
-
-struct PL_V4L2Source_Internal
-{
- uint8_t* buffer;
- int buffSize;
- size_t buffSizeMax;
- bool payError;
-
- MB_Frame lastFrame;
- PL_V4L2Source_Config config;
-
- V4l2Capture* videoCapture;
-
- PL_V4L2Source_Internal() :
- buffer(nullptr), buffSize(0), buffSizeMax(0), payError(true),
- lastFrame(), config(),
- videoCapture(nullptr)
- {
- }
-
- ~PL_V4L2Source_Internal()
- {
- delete[] buffer;
- buffer = nullptr;
- }
-
- void reset()
- {
- buffSize = 0;
- payError = true;
-
- MB_Frame _lastFrame;
- lastFrame = _lastFrame;
-
- PL_V4L2Source_Config _config;
- config = _config;
-
- if (buffer != nullptr)
- {
- delete[] buffer;
- buffer = nullptr;
- buffSizeMax = 0;
- }
- }
-};
-
-PipeLineElem* create_PL_V4L2Source()
-{
- return new PL_V4L2Source;
-}
-
-PL_V4L2Source::PL_V4L2Source() : internal(new PL_V4L2Source_Internal)
-{
-}
-
-PL_V4L2Source::~PL_V4L2Source()
-{
- PL_V4L2Source_Internal* in = (PL_V4L2Source_Internal*)internal;
- delete in;
-}
-
-bool PL_V4L2Source::init(void* args)
-{
- PL_V4L2Source_Internal* in = (PL_V4L2Source_Internal*)internal;
- in->reset();
-
- if (args != nullptr)
- {
- PL_V4L2Source_Config* config = (PL_V4L2Source_Config*)args;
- in->config = *config;
- }
-
- // init V4L2 capture interface
- V4L2DeviceParameters param(in->config.device.c_str(), in->config.format, in->config.width, in->config.height, in->config.fps, 1+1);
- in->videoCapture = V4l2Capture::create(param, (V4l2Access::IoType)in->config.ioType);
-
- if (in->videoCapture != nullptr)
- {
- in->buffSizeMax = in->videoCapture->getBufferSize();
- in->buffer = new uint8_t[in->buffSizeMax];
- }
-
- return in->videoCapture != nullptr;
-}
-
-void PL_V4L2Source::finit()
-{
- PL_V4L2Source_Internal* in = (PL_V4L2Source_Internal*)internal;
-
- // close videoCapture
- //#todo
-}
-
-bool PL_V4L2Source::pay(const PipeMaterial& pm)
-{
- return false;
-}
-
-bool PL_V4L2Source::gain(PipeMaterial& pm)
-{
- PL_V4L2Source_Internal* in = (PL_V4L2Source_Internal*)internal;
-
- pm.former = this;
- pm.deleter = nullptr;
- pm.args = nullptr;
-
- uint8_t tmpYUYV[in->config.width * in->config.height * 2];
- in->buffSize = in->videoCapture->read((char*)tmpYUYV, sizeof(tmpYUYV));
- if (in->buffSize <= 0 && errno != EAGAIN)
- {
- LOG(NOTICE) << "videoCapture stopped " << strerror(errno) << LOG_ENDL;
- return false;
- }
-
- uint8_t* dst_y = (uint8_t*)(in->buffer);
- uint8_t* dst_u = (uint8_t*)(dst_y + (in->config.width * in->config.height));
- uint8_t* dst_v = (uint8_t*)(dst_u + (in->config.width * in->config.height / 4));
-
- //libyuv::YUY2ToI420(tmpYUYV, in->config.width*2,
- // dst_y, in->config.width,
- // dst_u, MH_SUBSAMPLE1(in->config.width, 2),
- // dst_v, MH_SUBSAMPLE1(in->config.width, 2),
- // in->config.width, in->config.height
- // );
- //in->lastFrame.type = MB_Frame::MBFT_YUV420;
-
- libyuv::YUY2ToNV12(tmpYUYV, in->config.width*2,
- dst_y, in->config.width,
- dst_u, in->config.width,
- in->config.width, in->config.height
- );
- in->lastFrame.type = MB_Frame::MBFT_NV12;
-
- in->lastFrame.buffer = in->buffer;
- in->lastFrame.buffSize = in->config.width * in->config.height * 1.5;
- in->lastFrame.width = in->videoCapture->getWidth();
- in->lastFrame.height = in->videoCapture->getHeight();
- in->lastFrame.pts = microseconds_to_timeval(0);
-
- pm.type = PipeMaterial::PMT_FRAME;
- pm.buffer = &(in->lastFrame);
- pm.buffSize = 0;
-
- return true;
-}
diff --git a/RtspFace/PL_V4L2Source.h b/RtspFace/PL_V4L2Source.h
deleted file mode 100644
index 0d82455..0000000
--- a/RtspFace/PL_V4L2Source.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// use https://github.com/mpromonet/libv4l2cpp
-
-#ifndef _PL_V4L2Source_H_
-#define _PL_V4L2Source_H_
-
-#include <linux/videodev2.h>
-#include "PipeLine.h"
-
-struct PL_V4L2Source_Config
-{
- std::string device;
- int ioType; // V4l2Access::IoType::IOTYPE_READWRITE=0, IOTYPE_MMAP=1
- int format;
- uint16_t width;
- uint16_t height;
- uint16_t fps;
-
- PL_V4L2Source_Config() :
- device("/dev/video0"), ioType(1), format(0), width(1280), height(720), fps(10)//V4L2_PIX_FMT_MJPEG
- { }
-};
-
-class PL_V4L2Source : public PipeLineElem
-{
-public:
- PL_V4L2Source();
- virtual ~PL_V4L2Source();
-
- virtual bool init(void* args);
- virtual void finit();
-
- virtual bool pay(const PipeMaterial& pm);
- virtual bool gain(PipeMaterial& pm);
-
-private:
- void* internal;
-};
-
-PipeLineElem* create_PL_V4L2Source();
-
-#endif
diff --git a/RtspFace/libv4l2cpp/LICENSE b/RtspFace/libv4l2cpp/LICENSE
deleted file mode 100644
index cf1ab25..0000000
--- a/RtspFace/libv4l2cpp/LICENSE
+++ /dev/null
@@ -1,24 +0,0 @@
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org>
diff --git a/RtspFace/libv4l2cpp/Makefile b/RtspFace/libv4l2cpp/Makefile
deleted file mode 100644
index 3c7b7d8..0000000
--- a/RtspFace/libv4l2cpp/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-CFLAGS = -W -Wall -pthread -g -pipe $(CFLAGS_EXTRA)
-CFLAGS += -I inc
-RM = rm -rf
-CC = gcc
-AR = ar
-
-V4L2WRAPPER_CPP:=$(wildcard src/*.cpp)
-V4L2WRAPPER_OBJ:=$(V4L2WRAPPER_CPP:%.cpp=%.o)
-
-.DEFAULT_GOAL := all
-
-all: libv4l2wrapper.a
-
-%.o: %.cpp
- $(CC) -c -o $@ $< $(CFLAGS)
-
-libv4l2wrapper.a: $(V4L2WRAPPER_OBJ)
- $(AR) rcs $@ $^
-
-
-clean:
- -@$(RM) *.a $(V4L2WRAPPER_OBJ)
diff --git a/RtspFace/libv4l2cpp/README.md b/RtspFace/libv4l2cpp/README.md
deleted file mode 100644
index afced79..0000000
--- a/RtspFace/libv4l2cpp/README.md
+++ /dev/null
@@ -1,47 +0,0 @@
-
-libv4l2cpp
-====================
-
-It is a C++ wrapper for V4L2
-
-License
-------------
-Domain public
-
-Dependencies
-------------
- - liblog4cpp5-dev
-
-V4L2 Capture
--------------
- - create a V4L2 Capture interface using MMAP interface:
-
- V4L2DeviceParameters param("/dev/video0", V4L2_PIX_FMT_*, width, height, fps, verbose);
- V4l2Capture* videoCapture = V4l2Capture::create(param, V4l2Access::IOTYPE_MMAP);
-
- - data are available :
-
- timeval timeout;
- bool isReadable = (videoCapture->isReadable(&timeout) == 1);
-
- - read data :
-
- size_t nb = videoCapture->read(buffer, bufferSize);
-
-
-V4L2 Output
--------------
-
- - To create a V4L2 Output interface using MMAP interface:
-
- V4L2DeviceParameters param("/dev/video0", V4L2_PIX_FMT_*, width, height, fps, verbose);
- V4l2Output* videoOutput = V4l2Output::create(param, V4l2Access::IOTYPE_MMAP);
-
- - data could be written :
-
- timeval timeout;
- bool isWritable = (videoOutput->isWritable(&timeout) == 1);
-
- - write data :
-
- size_t nb = videoOutput->write(buffer, bufferSize);
diff --git a/RtspFace/libv4l2cpp/inc/V4l2Access.h b/RtspFace/libv4l2cpp/inc/V4l2Access.h
deleted file mode 100644
index 39ef676..0000000
--- a/RtspFace/libv4l2cpp/inc/V4l2Access.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Access.h
-**
-** V4L2 wrapper
-**
-** -------------------------------------------------------------------------*/
-
-
-#ifndef V4L2_ACCESS
-#define V4L2_ACCESS
-
-#include "V4l2Device.h"
-
-class V4l2Access
-{
- public:
- enum IoType
- {
- IOTYPE_READWRITE,
- IOTYPE_MMAP,
- };
-
- V4l2Access(V4l2Device* device) : m_device(device) {}
- virtual ~V4l2Access() { delete m_device; }
-
- int getFd() { return m_device->getFd(); }
- int getBufferSize() { return m_device->getBufferSize(); }
- int getFormat() { return m_device->getFormat(); }
- int getWidth() { return m_device->getWidth(); }
- int getHeight() { return m_device->getHeight(); }
- void queryFormat() { m_device->queryFormat(); }
-
- int isReady() { return m_device->isReady(); }
- int start() { return m_device->start(); }
- int stop() { return m_device->stop(); }
-
- private:
- V4l2Access(const V4l2Access&);
- V4l2Access & operator=(const V4l2Access&);
-
- protected:
- V4l2Device* m_device;
-};
-
-
-#endif
diff --git a/RtspFace/libv4l2cpp/inc/V4l2Capture.h b/RtspFace/libv4l2cpp/inc/V4l2Capture.h
deleted file mode 100644
index 44b0d18..0000000
--- a/RtspFace/libv4l2cpp/inc/V4l2Capture.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Capture.h
-**
-** V4L2 Capture wrapper
-**
-** -------------------------------------------------------------------------*/
-
-
-#ifndef V4L2_CAPTURE
-#define V4L2_CAPTURE
-
-#include "V4l2Access.h"
-
-// ---------------------------------
-// V4L2 Capture
-// ---------------------------------
-class V4l2Capture : public V4l2Access
-{
- protected:
- V4l2Capture(V4l2Device* device);
-
- public:
- static V4l2Capture* create(const V4L2DeviceParameters & param, IoType iotype = V4l2Access::IOTYPE_MMAP);
-
- size_t read(char* buffer, size_t bufferSize);
- int isReadable(timeval* tv);
-};
-
-
-#endif
diff --git a/RtspFace/libv4l2cpp/inc/V4l2Device.h b/RtspFace/libv4l2cpp/inc/V4l2Device.h
deleted file mode 100644
index d6fc407..0000000
--- a/RtspFace/libv4l2cpp/inc/V4l2Device.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Device.h
-**
-** V4L2 wrapper
-**
-** -------------------------------------------------------------------------*/
-
-
-#ifndef V4L2_DEVICE
-#define V4L2_DEVICE
-
-#include <string>
-#include <linux/videodev2.h>
-
-#ifndef V4L2_PIX_FMT_VP8
-#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0')
-#endif
-#ifndef V4L2_PIX_FMT_VP9
-#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0')
-#endif
-
-// ---------------------------------
-// V4L2 Device parameters
-// ---------------------------------
-struct V4L2DeviceParameters
-{
- V4L2DeviceParameters(const char* devname, unsigned int format, unsigned int width, unsigned int height, int fps, int verbose) :
- m_devName(devname), m_format(format), m_width(width), m_height(height), m_fps(fps), m_verbose(verbose) {};
-
- std::string m_devName;
- unsigned int m_format;
- unsigned int m_width;
- unsigned int m_height;
- int m_fps;
- int m_verbose;
-};
-
-// ---------------------------------
-// V4L2 Device
-// ---------------------------------
-class V4l2Device
-{
- friend class V4l2Capture;
- friend class V4l2Output;
-
- protected:
- void close();
-
- int initdevice(const char *dev_name, unsigned int mandatoryCapabilities);
- int checkCapabilities(int fd, unsigned int mandatoryCapabilities);
- int configureFormat(int fd);
- int configureParam(int fd);
-
- virtual bool init(unsigned int mandatoryCapabilities);
- virtual size_t writeInternal(char*, size_t) { return -1; };
- virtual size_t readInternal(char*, size_t) { return -1; };
-
- public:
- V4l2Device(const V4L2DeviceParameters& params, v4l2_buf_type deviceType);
- virtual ~V4l2Device();
-
- virtual bool isReady() { return (m_fd != -1); }
- virtual bool start() { return true; }
- virtual bool stop() { return true; }
-
- int getBufferSize() { return m_bufferSize; }
- int getFormat() { return m_format; }
- int getWidth() { return m_width; }
- int getHeight() { return m_height; }
- int getFd() { return m_fd; }
- void queryFormat();
-
- protected:
- V4L2DeviceParameters m_params;
- int m_fd;
- v4l2_buf_type m_deviceType;
-
- int m_bufferSize;
- int m_format;
- int m_width;
- int m_height;
-};
-
-
-#endif
diff --git a/RtspFace/libv4l2cpp/inc/V4l2MmapDevice.h b/RtspFace/libv4l2cpp/inc/V4l2MmapDevice.h
deleted file mode 100644
index 313e41f..0000000
--- a/RtspFace/libv4l2cpp/inc/V4l2MmapDevice.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2MmapDevice.h
-**
-** V4L2 source using mmap API
-**
-** -------------------------------------------------------------------------*/
-
-
-#ifndef V4L2_MMAP_DEVICE
-#define V4L2_MMAP_DEVICE
-
-#include "V4l2Device.h"
-
-#define V4L2MMAP_NBBUFFER 10
-
-class V4l2MmapDevice : public V4l2Device
-{
- protected:
- size_t writeInternal(char* buffer, size_t bufferSize);
- size_t readInternal(char* buffer, size_t bufferSize);
-
- public:
- V4l2MmapDevice(const V4L2DeviceParameters & params, v4l2_buf_type deviceType);
- virtual ~V4l2MmapDevice();
-
- virtual bool init(unsigned int mandatoryiCapabilities);
- virtual bool isReady() { return ((m_fd != -1)&& (n_buffers != 0)); };
- virtual bool start();
- virtual bool stop();
-
- protected:
- unsigned int n_buffers;
-
- struct buffer
- {
- void * start;
- size_t length;
- };
- buffer m_buffer[V4L2MMAP_NBBUFFER];
-};
-
-#endif
-
diff --git a/RtspFace/libv4l2cpp/inc/V4l2Output.h b/RtspFace/libv4l2cpp/inc/V4l2Output.h
deleted file mode 100644
index 055c683..0000000
--- a/RtspFace/libv4l2cpp/inc/V4l2Output.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Output.h
-**
-** V4L2 Output wrapper
-**
-** -------------------------------------------------------------------------*/
-
-
-#ifndef V4L2_OUTPUT
-#define V4L2_OUTPUT
-
-#include "V4l2Access.h"
-
-// ---------------------------------
-// V4L2 Output
-// ---------------------------------
-class V4l2Output : public V4l2Access
-{
- protected:
- V4l2Output(V4l2Device* device);
-
- public:
- static V4l2Output* create(const V4L2DeviceParameters & param, IoType iotype = V4l2Access::IOTYPE_MMAP);
-
- size_t write(char* buffer, size_t bufferSize);
- int isWritable(timeval* tv);
-};
-
-#endif
diff --git a/RtspFace/libv4l2cpp/inc/V4l2ReadWriteDevice.h b/RtspFace/libv4l2cpp/inc/V4l2ReadWriteDevice.h
deleted file mode 100644
index 59fc1ad..0000000
--- a/RtspFace/libv4l2cpp/inc/V4l2ReadWriteDevice.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2ReadWriteDevice.h
-**
-** V4L2 source using read/write API
-**
-** -------------------------------------------------------------------------*/
-
-
-#ifndef V4L2_RW_DEVICE
-#define V4L2_RW_DEVICE
-
-#include "V4l2Device.h"
-
-
-class V4l2ReadWriteDevice : public V4l2Device
-{
- protected:
- virtual size_t writeInternal(char* buffer, size_t bufferSize) { return ::write(m_fd, buffer, bufferSize); };
- virtual size_t readInternal(char* buffer, size_t bufferSize) { return ::read(m_fd, buffer, bufferSize); };
-
- public:
- V4l2ReadWriteDevice(const V4L2DeviceParameters& params, v4l2_buf_type deviceType) : V4l2Device(params, deviceType) {};
-
-};
-
-
-#endif
-
diff --git a/RtspFace/libv4l2cpp/inc/logger.h.bak b/RtspFace/libv4l2cpp/inc/logger.h.bak
deleted file mode 100644
index d96116f..0000000
--- a/RtspFace/libv4l2cpp/inc/logger.h.bak
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** logger.h
-**
-** -------------------------------------------------------------------------*/
-
-#ifndef LOGGER_H
-#define LOGGER_H
-
-#include <unistd.h>
-
-#include "log4cpp/Category.hh"
-#include "log4cpp/FileAppender.hh"
-#include "log4cpp/PatternLayout.hh"
-
-
-#define LOG(__level) log4cpp::Category::getRoot() << log4cpp::Priority::__level << __FILE__ << ":" << __LINE__ << "\n\t"
-
-inline void initLogger(int verbose)
-{
- // initialize log4cpp
- log4cpp::Category &log = log4cpp::Category::getRoot();
- log4cpp::Appender *app = new log4cpp::FileAppender("root", fileno(stdout));
- if (app)
- {
- log4cpp::PatternLayout *plt = new log4cpp::PatternLayout();
- if (plt)
- {
- plt->setConversionPattern("%d [%-6p] - %m%n");
- app->setLayout(plt);
- }
- log.addAppender(app);
- }
- switch (verbose)
- {
- case 2: log.setPriority(log4cpp::Priority::DEBUG); break;
- case 1: log.setPriority(log4cpp::Priority::INFO); break;
- default: log.setPriority(log4cpp::Priority::NOTICE); break;
-
- }
- LOG(INFO) << "level:" << log4cpp::Priority::getPriorityName(log.getPriority());
-}
-
-#endif
-
diff --git a/RtspFace/libv4l2cpp/src/V4l2Capture.cpp b/RtspFace/libv4l2cpp/src/V4l2Capture.cpp
deleted file mode 100644
index 71b03c0..0000000
--- a/RtspFace/libv4l2cpp/src/V4l2Capture.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Capture.cpp
-**
-** V4L2 wrapper
-**
-** -------------------------------------------------------------------------*/
-
-
-// libv4l2
-#include <linux/videodev2.h>
-
-// project
-#include "logger.h"
-#include "V4l2Capture.h"
-#include "V4l2MmapDevice.h"
-#include "V4l2ReadWriteDevice.h"
-
-
-// -----------------------------------------
-// create video capture interface
-// -----------------------------------------
-V4l2Capture* V4l2Capture::create(const V4L2DeviceParameters & param, IoType iotype)
-{
- V4l2Capture* videoCapture = NULL;
- V4l2Device* videoDevice = NULL;
- int caps = V4L2_CAP_VIDEO_CAPTURE;
- switch (iotype)
- {
- case IOTYPE_MMAP:
- videoDevice = new V4l2MmapDevice(param, V4L2_BUF_TYPE_VIDEO_CAPTURE);
- caps |= V4L2_CAP_STREAMING;
- break;
- default:
- videoDevice = new V4l2ReadWriteDevice(param, V4L2_BUF_TYPE_VIDEO_CAPTURE);
- caps |= V4L2_CAP_READWRITE;
- break;
- }
-
- if (videoDevice && !videoDevice->init(caps))
- {
- delete videoDevice;
- videoDevice=NULL;
- }
-
- if (videoDevice)
- {
- videoCapture = new V4l2Capture(videoDevice);
- }
- return videoCapture;
-}
-
-// -----------------------------------------
-// constructor
-// -----------------------------------------
-V4l2Capture::V4l2Capture(V4l2Device* device) : V4l2Access(device)
-{
-}
-
-// -----------------------------------------
-// check readability
-// -----------------------------------------
-int V4l2Capture::isReadable(timeval* tv)
-{
- int fd = m_device->getFd();
- fd_set fdset;
- FD_ZERO(&fdset);
- FD_SET(fd, &fdset);
- return select(fd+1, &fdset, NULL, NULL, tv);
-}
-
-// -----------------------------------------
-// read from V4l2Device
-// -----------------------------------------
-size_t V4l2Capture::read(char* buffer, size_t bufferSize)
-{
- return m_device->readInternal(buffer, bufferSize);
-}
-
-
diff --git a/RtspFace/libv4l2cpp/src/V4l2Device.cpp b/RtspFace/libv4l2cpp/src/V4l2Device.cpp
deleted file mode 100644
index ba33c0a..0000000
--- a/RtspFace/libv4l2cpp/src/V4l2Device.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Device.cpp
-**
-** -------------------------------------------------------------------------*/
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-
-// libv4l2
-#include <linux/videodev2.h>
-#include <linux/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "logger.h"
-
-#include "V4l2Device.h"
-
-// -----------------------------------------
-// V4L2Device
-// -----------------------------------------
-V4l2Device::V4l2Device(const V4L2DeviceParameters& params, v4l2_buf_type deviceType) : m_params(params), m_fd(-1), m_deviceType(deviceType), m_bufferSize(0), m_format(0)
-{
-}
-
-V4l2Device::~V4l2Device()
-{
- this->close();
-}
-
-void V4l2Device::close()
-{
- if (m_fd != -1)
- ::close(m_fd);
-
- m_fd = -1;
-}
-
-// query current format
-void V4l2Device::queryFormat()
-{
- struct v4l2_format fmt;
- memset(&fmt,0,sizeof(fmt));
- fmt.type = m_deviceType;
- if (0 == ioctl(m_fd,VIDIOC_G_FMT,&fmt))
- {
- m_format = fmt.fmt.pix.pixelformat;
- m_width = fmt.fmt.pix.width;
- m_height = fmt.fmt.pix.height;
- m_bufferSize = fmt.fmt.pix.sizeimage;
- }
-}
-
-// intialize the V4L2 connection
-bool V4l2Device::init(unsigned int mandatoryCapabilities)
-{
- struct stat sb;
- if ( (stat(m_params.m_devName.c_str(), &sb)==0) && ((sb.st_mode & S_IFMT) == S_IFCHR) )
- {
- if (initdevice(m_params.m_devName.c_str(), mandatoryCapabilities) == -1)
- {
- LOG(ERROR) << "Cannot init device:" << m_params.m_devName << LOG_ENDL;
- }
- }
- else
- {
- // open a normal file
- m_fd = open(m_params.m_devName.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
- }
- return (m_fd!=-1);
-}
-
-// intialize the V4L2 device
-int V4l2Device::initdevice(const char *dev_name, unsigned int mandatoryCapabilities)
-{
- m_fd = open(dev_name, O_RDWR | O_NONBLOCK);
- if (m_fd < 0)
- {
- LOG(ERROR) << "Cannot open device:" << m_params.m_devName << " " << strerror(errno) << LOG_ENDL;
- this->close();
- return -1;
- }
- if (checkCapabilities(m_fd,mandatoryCapabilities) !=0)
- {
- this->close();
- return -1;
- }
- if (configureFormat(m_fd) !=0)
- {
- this->close();
- return -1;
- }
- if (configureParam(m_fd) !=0)
- {
- this->close();
- return -1;
- }
-
- return m_fd;
-}
-
-// check needed V4L2 capabilities
-int V4l2Device::checkCapabilities(int fd, unsigned int mandatoryCapabilities)
-{
- struct v4l2_capability cap;
- memset(&(cap), 0, sizeof(cap));
- if (-1 == ioctl(fd, VIDIOC_QUERYCAP, &cap))
- {
- LOG(ERROR) << "Cannot get capabilities for device:" << m_params.m_devName << " " << strerror(errno) << LOG_ENDL;
- return -1;
- }
- LOG(NOTICE) << "driver:" << cap.driver << " " << std::hex << cap.capabilities << LOG_ENDL;
-
- if ((cap.capabilities & V4L2_CAP_READWRITE)) LOG(NOTICE) << m_params.m_devName << " support read/write" << LOG_ENDL;
- if ((cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) LOG(NOTICE) << m_params.m_devName << " support output" << LOG_ENDL;
- if ((cap.capabilities & V4L2_CAP_STREAMING)) LOG(NOTICE) << m_params.m_devName << " support streaming" << LOG_ENDL;
- if ((cap.capabilities & V4L2_CAP_TIMEPERFRAME)) LOG(NOTICE) << m_params.m_devName << " support timeperframe" << LOG_ENDL;
-
- if ( (cap.capabilities & mandatoryCapabilities) != mandatoryCapabilities )
- {
- LOG(ERROR) << "Mandatory capability not available for device:" << m_params.m_devName << LOG_ENDL;
- return -1;
- }
-
- return 0;
-}
-
-std::string fourcc(unsigned int format)
-{
- char formatArray[] = { (char)(format&0xff), (char)((format>>8)&0xff), (char)((format>>16)&0xff), (char)((format>>24)&0xff), 0 };
- return std::string(formatArray, strlen(formatArray));
-}
-
-// configure capture format
-int V4l2Device::configureFormat(int fd)
-{
-
- if (m_params.m_format==0)
- {
- this->queryFormat();
- m_params.m_format = m_format;
- m_params.m_width = m_width;
- m_params.m_height = m_height;
- }
-
- struct v4l2_format fmt;
- memset(&(fmt), 0, sizeof(fmt));
- fmt.type = m_deviceType;
- fmt.fmt.pix.width = m_params.m_width;
- fmt.fmt.pix.height = m_params.m_height;
- fmt.fmt.pix.pixelformat = m_params.m_format;
- fmt.fmt.pix.field = V4L2_FIELD_ANY;
-
- if (ioctl(fd, VIDIOC_S_FMT, &fmt) == -1)
- {
- LOG(ERROR) << "Cannot set format for device:" << m_params.m_devName << " " << strerror(errno) << LOG_ENDL;
- return -1;
- }
- if (fmt.fmt.pix.pixelformat != m_params.m_format)
- {
- LOG(ERROR) << "Cannot set pixelformat to:" << fourcc(m_params.m_format) << " format is:" << fourcc(fmt.fmt.pix.pixelformat) << LOG_ENDL;
- return -1;
- }
- if ((fmt.fmt.pix.width != m_params.m_width) || (fmt.fmt.pix.height != m_params.m_height))
- {
- LOG(WARN) << "Cannot set size width:" << fmt.fmt.pix.width << " height:" << fmt.fmt.pix.height << LOG_ENDL;
- }
-
- m_format = fmt.fmt.pix.pixelformat;
- m_width = fmt.fmt.pix.width;
- m_height = fmt.fmt.pix.height;
- m_bufferSize = fmt.fmt.pix.sizeimage;
-
- LOG(NOTICE) << m_params.m_devName << ":" << fourcc(m_format) << " size:" << m_params.m_width << "x" << m_params.m_height << " bufferSize:" << m_bufferSize << LOG_ENDL;
-
- return 0;
-}
-
-// configure capture FPS
-int V4l2Device::configureParam(int fd)
-{
- if (m_params.m_fps!=0)
- {
- struct v4l2_streamparm param;
- memset(&(param), 0, sizeof(param));
- param.type = m_deviceType;
- param.parm.capture.timeperframe.numerator = 1;
- param.parm.capture.timeperframe.denominator = m_params.m_fps;
-
- if (ioctl(fd, VIDIOC_S_PARM, ¶m) == -1)
- {
- LOG(WARN) << "Cannot set param for device:" << m_params.m_devName << " " << strerror(errno) << LOG_ENDL;
- }
-
- LOG(NOTICE) << "fps:" << param.parm.capture.timeperframe.numerator << "/" << param.parm.capture.timeperframe.denominator << LOG_ENDL;
- LOG(NOTICE) << "nbBuffer:" << param.parm.capture.readbuffers << LOG_ENDL;
- }
-
- return 0;
-}
-
-
diff --git a/RtspFace/libv4l2cpp/src/V4l2MmapDevice.cpp b/RtspFace/libv4l2cpp/src/V4l2MmapDevice.cpp
deleted file mode 100644
index 7018508..0000000
--- a/RtspFace/libv4l2cpp/src/V4l2MmapDevice.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2MmapDevice.cpp
-**
-** V4L2 source using mmap API
-**
-** -------------------------------------------------------------------------*/
-
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-
-// libv4l2
-#include <linux/videodev2.h>
-
-// project
-#include "logger.h"
-#include "V4l2MmapDevice.h"
-
-V4l2MmapDevice::V4l2MmapDevice(const V4L2DeviceParameters & params, v4l2_buf_type deviceType) : V4l2Device(params, deviceType), n_buffers(0)
-{
- memset(&m_buffer, 0, sizeof(m_buffer));
-}
-
-bool V4l2MmapDevice::init(unsigned int mandatoryCapabilities)
-{
- bool ret = V4l2Device::init(mandatoryCapabilities);
- if (ret)
- {
- this->start();
- }
- return ret;
-}
-
-V4l2MmapDevice::~V4l2MmapDevice()
-{
- this->stop();
-}
-
-
-bool V4l2MmapDevice::start()
-{
- bool success = true;
- struct v4l2_requestbuffers req;
- memset (&req, 0, sizeof(req));
- req.count = V4L2MMAP_NBBUFFER;
- req.type = m_deviceType;
- req.memory = V4L2_MEMORY_MMAP;
-
- if (-1 == ioctl(m_fd, VIDIOC_REQBUFS, &req))
- {
- if (EINVAL == errno)
- {
- LOG(ERROR) << "Device " << m_params.m_devName << " does not support memory mapping" << LOG_ENDL;
- success = false;
- }
- else
- {
- perror("VIDIOC_REQBUFS");
- success = false;
- }
- }
- else
- {
- LOG(NOTICE) << "Device " << m_params.m_devName << " nb buffer:" << req.count << LOG_ENDL;
-
- // allocate buffers
- memset(&m_buffer,0, sizeof(m_buffer));
- for (n_buffers = 0; n_buffers < req.count; ++n_buffers)
- {
- struct v4l2_buffer buf;
- memset (&buf, 0, sizeof(buf));
- buf.type = m_deviceType;
- buf.memory = V4L2_MEMORY_MMAP;
- buf.index = n_buffers;
-
- if (-1 == ioctl(m_fd, VIDIOC_QUERYBUF, &buf))
- {
- perror("VIDIOC_QUERYBUF");
- success = false;
- }
- else
- {
- LOG(INFO) << "Device " << m_params.m_devName << " buffer idx:" << n_buffers << " size:" << buf.length << LOG_ENDL;
- m_buffer[n_buffers].length = buf.length;
- m_buffer[n_buffers].start = mmap ( NULL /* start anywhere */,
- buf.length,
- PROT_READ | PROT_WRITE /* required */,
- MAP_SHARED /* recommended */,
- m_fd,
- buf.m.offset);
-
- if (MAP_FAILED == m_buffer[n_buffers].start)
- {
- perror("mmap");
- success = false;
- }
- }
- }
-
- // queue buffers
- for (unsigned int i = 0; i < n_buffers; ++i)
- {
- struct v4l2_buffer buf;
- memset (&buf, 0, sizeof(buf));
- buf.type = m_deviceType;
- buf.memory = V4L2_MEMORY_MMAP;
- buf.index = i;
-
- if (-1 == ioctl(m_fd, VIDIOC_QBUF, &buf))
- {
- perror("VIDIOC_QBUF");
- success = false;
- }
- }
-
- // start stream
- int type = m_deviceType;
- if (-1 == ioctl(m_fd, VIDIOC_STREAMON, &type))
- {
- perror("VIDIOC_STREAMON");
- success = false;
- }
- }
- return success;
-}
-
-bool V4l2MmapDevice::stop()
-{
- bool success = true;
-
- int type = m_deviceType;
- if (-1 == ioctl(m_fd, VIDIOC_STREAMOFF, &type))
- {
- perror("VIDIOC_STREAMOFF");
- success = false;
- }
-
- for (unsigned int i = 0; i < n_buffers; ++i)
- {
- if (-1 == munmap (m_buffer[i].start, m_buffer[i].length))
- {
- perror("munmap");
- success = false;
- }
- }
-
- // free buffers
- struct v4l2_requestbuffers req;
- memset (&req, 0, sizeof(req));
- req.count = 0;
- req.type = m_deviceType;
- req.memory = V4L2_MEMORY_MMAP;
- if (-1 == ioctl(m_fd, VIDIOC_REQBUFS, &req))
- {
- perror("VIDIOC_REQBUFS");
- success = false;
- }
-
- n_buffers = 0;
- return success;
-}
-
-size_t V4l2MmapDevice::readInternal(char* buffer, size_t bufferSize)
-{
- size_t size = 0;
- if (n_buffers > 0)
- {
- struct v4l2_buffer buf;
- memset (&buf, 0, sizeof(buf));
- buf.type = m_deviceType;
- buf.memory = V4L2_MEMORY_MMAP;
-
- if (-1 == ioctl(m_fd, VIDIOC_DQBUF, &buf))
- {
- perror("VIDIOC_DQBUF");
- size = -1;
- }
- else if (buf.index < n_buffers)
- {
- size = buf.bytesused;
- if (size > bufferSize)
- {
- size = bufferSize;
- LOG(WARN) << "Device " << m_params.m_devName << " buffer truncated available:" << bufferSize << " needed:" << buf.bytesused << LOG_ENDL;
- }
- memcpy(buffer, m_buffer[buf.index].start, size);
-
- if (-1 == ioctl(m_fd, VIDIOC_QBUF, &buf))
- {
- perror("VIDIOC_QBUF");
- size = -1;
- }
- }
- }
- return size;
-}
-
-size_t V4l2MmapDevice::writeInternal(char* buffer, size_t bufferSize)
-{
- size_t size = 0;
- if (n_buffers > 0)
- {
- struct v4l2_buffer buf;
- memset (&buf, 0, sizeof(buf));
- buf.type = m_deviceType;
- buf.memory = V4L2_MEMORY_MMAP;
-
- if (-1 == ioctl(m_fd, VIDIOC_DQBUF, &buf))
- {
- perror("VIDIOC_DQBUF");
- size = -1;
- }
- else if (buf.index < n_buffers)
- {
- size = bufferSize;
- if (size > buf.length)
- {
- size = buf.length;
- LOG(WARN) << "Device " << m_params.m_devName << " buffer truncated available:" << buf.length << " needed:" << size << LOG_ENDL;
- }
- memcpy(m_buffer[buf.index].start, buffer, size);
- buf.bytesused = size;
-
- if (-1 == ioctl(m_fd, VIDIOC_QBUF, &buf))
- {
- perror("VIDIOC_QBUF");
- size = -1;
- }
- }
- }
- return size;
-}
-
-
-
-
diff --git a/RtspFace/libv4l2cpp/src/V4l2Output.cpp b/RtspFace/libv4l2cpp/src/V4l2Output.cpp
deleted file mode 100644
index 99b37f4..0000000
--- a/RtspFace/libv4l2cpp/src/V4l2Output.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ---------------------------------------------------------------------------
-** This software is in the public domain, furnished "as is", without technical
-** support, and with no warranty, express or implied, as to its usefulness for
-** any purpose.
-**
-** V4l2Output.cpp
-**
-** V4L2 wrapper
-**
-** -------------------------------------------------------------------------*/
-
-#include <string.h>
-
-// libv4l2
-#include <linux/videodev2.h>
-
-// project
-#include "logger.h"
-
-#include "V4l2Output.h"
-#include "V4l2MmapDevice.h"
-#include "V4l2ReadWriteDevice.h"
-
-// -----------------------------------------
-// create video output interface
-// -----------------------------------------
-V4l2Output* V4l2Output::create(const V4L2DeviceParameters & param, IoType iotype)
-{
- V4l2Output* videoOutput = NULL;
- V4l2Device* videoDevice = NULL;
- int caps = V4L2_CAP_VIDEO_OUTPUT;
- switch (iotype)
- {
- case IOTYPE_MMAP:
- videoDevice = new V4l2MmapDevice(param, V4L2_BUF_TYPE_VIDEO_OUTPUT);
- caps |= V4L2_CAP_STREAMING;
- break;
- default:
- videoDevice = new V4l2ReadWriteDevice(param, V4L2_BUF_TYPE_VIDEO_OUTPUT);
- caps |= V4L2_CAP_READWRITE;
- break;
- }
-
- if (videoDevice && !videoDevice->init(caps))
- {
- delete videoDevice;
- videoDevice=NULL;
- }
-
- if (videoDevice)
- {
- videoOutput = new V4l2Output(videoDevice);
- }
- return videoOutput;
-}
-
-// -----------------------------------------
-// constructor
-// -----------------------------------------
-V4l2Output::V4l2Output(V4l2Device* device) : V4l2Access(device)
-{
-}
-
-// -----------------------------------------
-// check writability
-// -----------------------------------------
-int V4l2Output::isWritable(timeval* tv)
-{
- int fd = m_device->getFd();
- fd_set fdset;
- FD_ZERO(&fdset);
- FD_SET(fd, &fdset);
- return select(fd+1, NULL, &fdset, NULL, tv);
-}
-
-// -----------------------------------------
-// write to V4l2Device
-// -----------------------------------------
-size_t V4l2Output::write(char* buffer, size_t bufferSize)
-{
- return m_device->writeInternal(buffer, bufferSize);
-}
diff --git a/RtspFace/main_raspicam_rtsp.cpp b/RtspFace/main_raspicam_rtsp.cpp
deleted file mode 100644
index e69e912..0000000
--- a/RtspFace/main_raspicam_rtsp.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-#include "PipeLine.h"
-#include "PL_RTSPServer.h"
-#include "PL_RaspiVid.h"
-
-#include "logger.h"
-#include <iostream>
-
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <cmdhub/client.h>
-
-#define CLOCKID CLOCK_REALTIME
-
-Logger g_logger(std::cout);
-
-time_t g_last_pipe_finished = 0;
-
-my_id_t get_my_id()
-{
- return 123;
-}
-
-std::string cmdhub_send_cmd(const std::string client_cmd)
-{
- CmdhubClientSession session;
- session.recv_retry = 5;
- if (!cmdhub_client_init(session))
- {
- LOG_ERROR << "cam_ir_timer cmdhub_client_init error" << LOG_ENDL;
- return "";
- }
- if (!cmdhub_client_connect(session))
- {
- LOG_ERROR << "cam_ir_timer cmdhub_client_connect error" << LOG_ENDL;
- return "";
- }
-
- std::string result;
- int exit_code;
- if (cmdhub_client_command(session, client_cmd, result, exit_code))
- {
- LOG_INFO << "exit_code:" << exit_code << ", result:" << result.c_str();
-
- cmdhub_client_destory(session);
- return result;
- }
-
- cmdhub_client_destory(session);
- return "";
-}
-
-static void cam_ir_timer(union sigval v)
-{
- LOGP(DEBUG, "checking IR %d", v.sival_int);
-
- if (time(nullptr) - g_last_pipe_finished < 5)
- {
- // camera should be closed
- cmdhub_send_cmd("exec/camirlighting camera_enable");
- }
- else
- {
- cmdhub_send_cmd("exec/camirlighting camera_disable");
- }
-}
-
-void start_cam_ir_timer()
-{
- timer_t timerid;
- struct sigevent evp;
- memset(&evp, 0, sizeof(struct sigevent));
-
- evp.sigev_value.sival_int = 123;
- evp.sigev_notify = SIGEV_THREAD;
- evp.sigev_notify_function = cam_ir_timer;
-
- if (timer_create(CLOCKID, &evp, &timerid) == -1)
- {
- LOG_ERROR << "fail to timer_create" << LOG_ENDL;
- exit(EXIT_FAILURE);
- }
-
- struct itimerspec it;
- it.it_interval.tv_sec = 5;
- it.it_interval.tv_nsec = 0;
- it.it_value.tv_sec = 5;
- it.it_value.tv_nsec = 0;
-
- if (timer_settime(timerid, 0, &it, NULL) == -1)
- {
- LOG_ERROR << "fail to timer_settime" << LOG_ENDL;
- exit(EXIT_FAILURE);
- }
-}
-
-int main(int argc, char** argv)
-{
- g_logger.set_level(INFO);
-
- PipeLine pipeLine;
-
- PipeLine::register_global_elem_creator("PL_RaspiVid", create_PL_RaspiVid);
- PipeLine::register_global_elem_creator("PL_RTSPServer", create_PL_RTSPServer);
-
- {
- PL_RaspiVid* raspiVid = (PL_RaspiVid*)pipeLine.push_elem("PL_RaspiVid");
- PL_RaspiVid_Config config;
- config.vflip = true;
- //config.profile = "baseline";
- //config.level = "4";
- bool ret = raspiVid->init(&config);
- if (!ret)
- {
- LOG_ERROR << "raspiVid.init error" << std::endl;
- exit(EXIT_FAILURE);
- }
- }
-
- {
- PL_RTSPServer* rtspServer = (PL_RTSPServer*)pipeLine.push_elem("PL_RTSPServer");
- bool ret = rtspServer->init(nullptr);
- if (!ret)
- {
- LOG_ERROR << "rtspServer.init error" << std::endl;
- exit(EXIT_FAILURE);
- }
- }
-
- cmdhub_send_cmd("exec/camirlighting bh1750_value");
- cmdhub_send_cmd("exec/camirlighting cam_ir_threshold 5");
-
- start_cam_ir_timer();
-
- while(true)
- {
- //LOG_ERROR << "begin pipe" << std::endl;
- pipeLine.pipe();
- //LOG_ERROR << "end pipe" << std::endl;
-
- g_last_pipe_finished = time(nullptr);
- }
-}
diff --git a/RtspFace/mediastreamer2/include/mediastreamer2/msjava.h b/RtspFace/mediastreamer2/include/mediastreamer2/msjava.h
deleted file mode 100644
index b0f8dc0..0000000
--- a/RtspFace/mediastreamer2/include/mediastreamer2/msjava.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-mediastreamer2 library - modular sound and video processing and streaming
-Copyright (C) 2010 Belledonne Communications SARL
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef msjava_h
-#define msjava_h
-
-/* Helper routines for filters that use a jvm with upcalls to perform some processing */
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-void ms_set_jvm(JavaVM *vm);
-
-JavaVM *ms_get_jvm(void);
-
-JNIEnv *ms_get_jni_env(void);
-
-#ifdef __ANDROID__
-int ms_get_android_sdk_version(void);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
-
diff --git a/RtspFace/mediastreamer2/src/android/android_mediacodec.cpp b/RtspFace/mediastreamer2/src/android/android_mediacodec.cpp
deleted file mode 100644
index 7f051d0..0000000
--- a/RtspFace/mediastreamer2/src/android/android_mediacodec.cpp
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
-mediastreamer2 android_mediacodec.cpp
-Copyright (C) 2015 Belledonne Communications SARL
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-//#include "mediastreamer2/mscommon.h"
-// https://github.com/BelledonneCommunications/ortp/blob/100146d7c09aea0bddcc6a10926f1ee528d42738/include/ortp/port.h
-#define ms_new0(type,count) (type*)malloc(sizeof(type)*(count))
-#define ms_free(ptr) free(ptr)
-
-static const int TRUE = 1;
-static const int FALSE = 0;
-
-#include "mediastreamer2/msjava.h"
-
-#include <media/NdkMediaCodec.h>
-#include <media/NdkMediaFormat.h>
-#include "android_mediacodec.h"
-
-#include "../../logger.h"
-
-////////////////////////////////////////////////////
-// //
-// MEDIA CODEC //
-// //
-////////////////////////////////////////////////////
-
-struct AMediaCodec {
- jobject jcodec;
- // mediaBufferInfo Class
- jmethodID _init_mediaBufferInfoClass;
- // MediaCodec Class
- jmethodID configure;
- jmethodID reset;
- jmethodID start;
- jmethodID release;
- jmethodID flush;
- jmethodID stop;
- jmethodID getInputBuffer;
- jmethodID getOutputBuffer;
- jmethodID dequeueInputBuffer;
- jmethodID queueInputBuffer;
- jmethodID dequeueOutputBuffer;
- jmethodID getOutputFormat;
- jmethodID getOutputImageMethod;
- jmethodID getInputImageMethod;
- jmethodID releaseOutputBuffer;
- jmethodID setParameters;
- // image Class
- jmethodID getFormatMethod;
- jmethodID getWidthMethod;
- jmethodID getHeightMethod;
- jmethodID getTimestrampMethod;
- jmethodID getPlanesMethod;
- jmethodID getCropRectMethod;
- // plane Class
- jmethodID getPixelStrideMethod;
- jmethodID getRowStrideMethod;
- jmethodID getBufferMethod;
- // Bundle Class
- jmethodID _init_BundleClass;
- jmethodID putIntId;
- // rect Class
- jfieldID bottomField;
- jfieldID leftField;
- jfieldID rightField;
- jfieldID topField;
- // mediaBufferInfo Class
- jfieldID size;
- jfieldID flags;
- jfieldID offset;
-};
-
-struct AMediaFormat {
- jobject jformat;
- // mediaFormat Class
- jmethodID setInteger;
- jmethodID getInteger;
- jmethodID setString;
-};
-
-int handle_java_exception() {
- JNIEnv *env = ms_get_jni_env();
- if (env->ExceptionCheck()) {
- env->ExceptionDescribe();
- env->ExceptionClear();
- return -1;
- }
- return 0;
-}
-
-static bool _loadClass(JNIEnv *env, const char *className, jclass *_class) {
- *_class = env->FindClass(className);
- if(handle_java_exception() == -1 || *_class == NULL) {
- LOGP(ERROR, "Could not load Java class [%s]", className);
- return false;
- }
- return true;
-}
-
-static bool _getMethodID(JNIEnv *env, jclass _class, const char *name, const char *sig, jmethodID *method) {
- *method = env->GetMethodID(_class, name, sig);
- if(handle_java_exception() == -1 || *method == NULL) {
- LOGP(ERROR, "Could not get method %s[%s]", name, sig);
- return false;
- }
- return true;
-}
-
-static bool _getStaticMethodID(JNIEnv *env, jclass _class, const char *name, const char *sig, jmethodID *method) {
- *method = env->GetStaticMethodID(_class, name, sig);
- if(handle_java_exception() == -1 || *method == NULL) {
- LOGP(ERROR, "Could not get static method %s[%s]", name, sig);
- return false;
- }
- return true;
-}
-
-static bool _getFieldID(JNIEnv *env, jclass _class, const char *name, const char *sig, jfieldID *field) {
- *field = env->GetFieldID(_class, name, sig);
- if(handle_java_exception() == -1 || *field == NULL) {
- LOGP(ERROR, "Could not get field %s[%s]", name, sig);
- return false;
- }
- return true;
-}
-
-bool AMediaCodec_loadMethodID(const char *createName, AMediaCodec *codec, const char *mime_type) {
- JNIEnv *env = ms_get_jni_env();
- jobject jcodec = NULL;
- jclass mediaCodecClass = NULL, imageClass = NULL, planeClass = NULL, rectClass = NULL, mediaBufferInfoClass = NULL, BundleClass = NULL;
- jmethodID createMethod = NULL;
- jstring msg = NULL;
- bool success = true;
-
- success &= _loadClass(env, "android/media/MediaCodec", &mediaCodecClass);
- success &= _loadClass(env, "android/media/Image", &imageClass);
- success &= _loadClass(env, "android/media/Image$Plane", &planeClass);
- success &= _loadClass(env, "android/graphics/Rect", &rectClass);
- success &= _loadClass(env, "android/media/MediaCodec$BufferInfo", &mediaBufferInfoClass);
- success &= _loadClass(env, "android/os/Bundle", &BundleClass);
- if (!success) {
- LOGP(ERROR, "%s(): one class could not be found", __FUNCTION__);
- goto error;
- }
-
- success &= _getStaticMethodID(env, mediaCodecClass, createName, "(Ljava/lang/String;)Landroid/media/MediaCodec;", &createMethod);
- success &= _getMethodID(env, mediaCodecClass, "configure", "(Landroid/media/MediaFormat;Landroid/view/Surface;Landroid/media/MediaCrypto;I)V", &(codec->configure));
- success &= _getMethodID(env, mediaCodecClass, "reset", "()V", &(codec->reset));
- success &= _getMethodID(env, mediaCodecClass, "start", "()V", &(codec->start));
- success &= _getMethodID(env, mediaCodecClass, "release", "()V", &(codec->release));
- success &= _getMethodID(env, mediaCodecClass, "flush", "()V", &(codec->flush));
- success &= _getMethodID(env, mediaCodecClass, "stop", "()V", &(codec->stop));
- success &= _getMethodID(env, mediaCodecClass, "getInputBuffer", "(I)Ljava/nio/ByteBuffer;", &(codec->getInputBuffer));
- success &= _getMethodID(env, mediaCodecClass, "getOutputBuffer","(I)Ljava/nio/ByteBuffer;", &(codec->getOutputBuffer));
- success &= _getMethodID(env, mediaCodecClass, "dequeueInputBuffer", "(J)I", &(codec->dequeueInputBuffer));
- success &= _getMethodID(env, mediaCodecClass, "queueInputBuffer", "(IIIJI)V", &(codec->queueInputBuffer));
- success &= _getMethodID(env, mediaCodecClass, "dequeueOutputBuffer", "(Landroid/media/MediaCodec$BufferInfo;J)I", &(codec->dequeueOutputBuffer));
- success &= _getMethodID(env, mediaCodecClass, "getOutputFormat", "()Landroid/media/MediaFormat;", &(codec->getOutputFormat));
- success &= _getMethodID(env, mediaCodecClass, "getInputImage", "(I)Landroid/media/Image;", &(codec->getInputImageMethod));
- success &= _getMethodID(env, mediaCodecClass, "getOutputImage", "(I)Landroid/media/Image;", &(codec->getOutputImageMethod));
- success &= _getMethodID(env, mediaCodecClass, "releaseOutputBuffer", "(IZ)V", &(codec->releaseOutputBuffer));
- success &= _getMethodID(env, mediaCodecClass, "setParameters", "(Landroid/os/Bundle;)V", &(codec->setParameters));
- success &= _getMethodID(env, imageClass, "getFormat", "()I", &(codec->getFormatMethod));
- success &= _getMethodID(env, imageClass, "getWidth", "()I", &(codec->getWidthMethod));
- success &= _getMethodID(env, imageClass, "getHeight", "()I", &(codec->getHeightMethod));
- success &= _getMethodID(env, imageClass, "getTimestamp", "()J", &(codec->getTimestrampMethod));
- success &= _getMethodID(env, imageClass, "getPlanes", "()[Landroid/media/Image$Plane;", &(codec->getPlanesMethod));
- success &= _getMethodID(env, imageClass, "getCropRect", "()Landroid/graphics/Rect;", &(codec->getCropRectMethod));
- success &= _getMethodID(env, planeClass, "getPixelStride", "()I", &(codec->getPixelStrideMethod));
- success &= _getMethodID(env, planeClass, "getRowStride", "()I", &(codec->getRowStrideMethod));
- success &= _getMethodID(env, planeClass, "getBuffer", "()Ljava/nio/ByteBuffer;", &(codec->getBufferMethod));
- success &= _getMethodID(env, mediaBufferInfoClass, "<init>", "()V", &(codec->_init_mediaBufferInfoClass));
- success &= _getMethodID(env, BundleClass,"<init>","()V", &(codec->_init_BundleClass));
- success &= _getMethodID(env, BundleClass,"putInt","(Ljava/lang/String;I)V", &(codec->putIntId));
- success &= _getFieldID(env, rectClass, "bottom", "I", &(codec->bottomField));
- success &= _getFieldID(env, rectClass, "left", "I", &(codec->leftField));
- success &= _getFieldID(env, rectClass, "right", "I", &(codec->rightField));
- success &= _getFieldID(env, rectClass, "top", "I", &(codec->topField));
- success &= _getFieldID(env, mediaBufferInfoClass, "size" , "I", &(codec->size));
- success &= _getFieldID(env, mediaBufferInfoClass, "flags" , "I", &(codec->flags));
- success &= _getFieldID(env, mediaBufferInfoClass, "offset" , "I", &(codec->offset));
- if(!success) {
- LOGP(ERROR, "%s(): one method or field could not be found", __FUNCTION__);
- goto error;
- }
-
- msg = env->NewStringUTF(mime_type);
- jcodec = env->CallStaticObjectMethod(mediaCodecClass, createMethod, msg);
- handle_java_exception();
- if (!jcodec) {
- LOGP(ERROR, "Failed to create codec !");
- goto error;
- }
-
- codec->jcodec = env->NewGlobalRef(jcodec);
- LOGP(INFO, "Codec %s successfully created.", mime_type);
-
- env->DeleteLocalRef(mediaCodecClass);
- env->DeleteLocalRef(jcodec);
- env->DeleteLocalRef(imageClass);
- env->DeleteLocalRef(planeClass);
- env->DeleteLocalRef(rectClass);
- env->DeleteLocalRef(BundleClass);
- env->DeleteLocalRef(msg);
- return true;
-
- error:
- if (mediaCodecClass) env->DeleteLocalRef(mediaCodecClass);
- if (jcodec) env->DeleteLocalRef(jcodec);
- if (imageClass) env->DeleteLocalRef(imageClass);
- if (planeClass) env->DeleteLocalRef(planeClass);
- if (rectClass) env->DeleteLocalRef(rectClass);
- if (BundleClass) env->DeleteLocalRef(BundleClass);
- if (msg) env->DeleteLocalRef(msg);
- return false;
-}
-
-AMediaCodec * AMediaCodec_createDecoderByType(const char *mime_type) {
- AMediaCodec *codec = ms_new0(AMediaCodec, 1);
- if (!AMediaCodec_loadMethodID("createDecoderByType", codec, mime_type)) {
- ms_free(codec);
- codec = NULL;
- }
- return codec;
-}
-
-AMediaCodec* AMediaCodec_createEncoderByType(const char *mime_type) {
- AMediaCodec *codec = ms_new0(AMediaCodec, 1);
- if (!AMediaCodec_loadMethodID("createEncoderByType", codec, mime_type)) {
- ms_free(codec);
- codec = NULL;
- }
- return codec;
-}
-
-media_status_t AMediaCodec_configure(AMediaCodec *codec, const AMediaFormat* format, ANativeWindow* surface, AMediaCrypto *crypto, uint32_t flags) {
- JNIEnv *env = ms_get_jni_env();
-
- //env->CallVoidMethod(codec->jcodec, codec->configure, format->jformat, NULL, NULL, flags);
- env->CallVoidMethod(codec->jcodec, codec->configure, format->jformat, NULL, NULL, flags);
-
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-media_status_t AMediaCodec_delete(AMediaCodec *codec) {
- JNIEnv *env = ms_get_jni_env();
-
- env->CallVoidMethod(codec->jcodec, codec->release);
- env->DeleteGlobalRef(codec->jcodec);
- ms_free(codec);
-
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-media_status_t AMediaCodec_start(AMediaCodec *codec) {
- JNIEnv *env = ms_get_jni_env();
-
- env->CallVoidMethod(codec->jcodec, codec->start);
-
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-media_status_t AMediaCodec_flush(AMediaCodec *codec) {
- JNIEnv *env = ms_get_jni_env();
-
- env->CallVoidMethod(codec->jcodec, codec->flush);
-
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-media_status_t AMediaCodec_stop(AMediaCodec *codec) {
- JNIEnv *env = ms_get_jni_env();
-
- env->CallVoidMethod(codec->jcodec, codec->stop);
-
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-
-uint8_t* AMediaCodec_getInputBuffer(AMediaCodec *codec, size_t idx, size_t *out_size) {
- JNIEnv *env = ms_get_jni_env();
- jobject jbuf = NULL;
- uint8_t *buf = NULL;
-
- jbuf = env->CallObjectMethod(codec->jcodec, codec->getInputBuffer, (jint) idx);
- if(jbuf != NULL){
- jlong capacity = env->GetDirectBufferCapacity(jbuf);
- *out_size = (size_t) capacity;
- buf = (uint8_t *) env->GetDirectBufferAddress(jbuf);
- env->DeleteLocalRef(jbuf);
- } else {
- LOGP(ERROR, "getInputBuffer() failed !");
- env->ExceptionClear();
- }
- handle_java_exception();
- return buf;
-}
-
-uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec *codec, size_t idx, size_t *out_size) {
- JNIEnv *env = ms_get_jni_env();
- jobject jbuf = NULL;
- uint8_t *buf = NULL;
- jlong capacity;
-
- jbuf = env->CallObjectMethod(codec->jcodec, codec->getOutputBuffer, (jint) idx);
- if (jbuf != NULL){
- buf = (uint8_t *) env->GetDirectBufferAddress(jbuf);
- capacity = env->GetDirectBufferCapacity(jbuf);
- *out_size = (size_t) capacity;
- env->DeleteLocalRef(jbuf);
- } else {
- LOGP(ERROR, "getOutputBuffer() failed !");
- env->ExceptionClear();
- }
- handle_java_exception();
- return buf;
-}
-
-ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec *codec, int64_t timeoutUs) {
- JNIEnv *env = ms_get_jni_env();
- jint jindex = -1;
-
- jindex = env->CallIntMethod(codec->jcodec, codec->dequeueInputBuffer, timeoutUs);
-
- /*return value to notify the exception*/
- /*otherwise, if -1 is returned as index, it just means that no buffer are available at this time (not an error)*/
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_UNKNOWN : (ssize_t) jindex;
-}
-
-media_status_t AMediaCodec_queueInputBuffer(AMediaCodec *codec, size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags) {
- JNIEnv *env = ms_get_jni_env();
-
- env->CallVoidMethod(codec->jcodec, codec->queueInputBuffer, idx, offset, size, time, flags);
-
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec *codec, AMediaCodecBufferInfo *info, int64_t timeoutUs) {
- JNIEnv *env = ms_get_jni_env();
- jint jindex = -1;
- jobject jinfo = NULL;
- jclass mediaBufferInfoClass;
-
- /* We can't stock jclass information due to JNIEnv difference between different threads */
- if(!_loadClass(env, "android/media/MediaCodec$BufferInfo", &mediaBufferInfoClass)) {
- LOGP(ERROR, "%s(): one class could not be found", __FUNCTION__);
- env->ExceptionClear();
- return AMEDIA_ERROR_UNKNOWN;
- }
-
- jinfo = env->NewObject(mediaBufferInfoClass, codec->_init_mediaBufferInfoClass);
-
- jindex = env->CallIntMethod(codec->jcodec, codec->dequeueOutputBuffer , jinfo, timeoutUs);
- if (env->ExceptionCheck()) {
- env->ExceptionDescribe();
- env->ExceptionClear();
- LOGP(ERROR, "Exception");
- jindex = AMEDIA_ERROR_UNKNOWN; /*return value to notify the exception*/
- /*otherwise, if -1 is returned as index, it just means that no buffer are available at this time (not an error)*/
- }
-
- if (jindex >= 0) {
- info->size = env->GetIntField(jinfo, codec->size);
- info->offset = env->GetIntField(jinfo, codec->offset);
- info->flags = env->GetIntField(jinfo, codec->flags);
- }
-
- env->DeleteLocalRef(mediaBufferInfoClass);
- env->DeleteLocalRef(jinfo);
- return (ssize_t) jindex;
-}
-
-AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec *codec) {
- AMediaFormat *format = AMediaFormat_new();
- JNIEnv *env = ms_get_jni_env();
- jobject jformat = NULL;
-
- jformat = env->CallObjectMethod(codec->jcodec, codec->getOutputFormat);
- handle_java_exception();
- if (!jformat) {
- LOGP(ERROR, "Failed to create format !");
- return NULL;
- }
-
- format->jformat = env->NewGlobalRef(jformat);
- env->DeleteLocalRef(jformat);
- return format;
-}
-
-media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec *codec, size_t idx, bool render) {
- JNIEnv *env = ms_get_jni_env();
- env->CallVoidMethod(codec->jcodec, codec->releaseOutputBuffer, (int)idx, FALSE);
- return (handle_java_exception() == -1) ? AMEDIA_ERROR_BASE : AMEDIA_OK;
-}
-
-void AMediaCodec_reset(AMediaCodec *codec) {
- JNIEnv *env = ms_get_jni_env();
- env->CallVoidMethod(codec->jcodec, codec->reset);
- handle_java_exception();
-}
-
-void AMediaCodec_setParams(AMediaCodec *codec, const char *params) {
- JNIEnv *env = ms_get_jni_env();
- jobject jbundle = NULL;
- jclass BundleClass = NULL;
-
- /* We can't stock jclass information due to JNIEnv difference between different threads */
- if (!_loadClass(env, "android/os/Bundle", &BundleClass)) {
- LOGP(ERROR, "%s(): one class could not be found", __FUNCTION__);
- handle_java_exception();
- return;
- }
-
- jstring msg = env->NewStringUTF(params);
- jbundle = env->NewObject(BundleClass, codec->_init_BundleClass);
- env->CallVoidMethod(jbundle, codec->putIntId, msg, 0);
- handle_java_exception();
- env->DeleteLocalRef(msg);
-
- env->CallVoidMethod(codec->jcodec, codec->setParameters, jbundle);
- handle_java_exception();
- env->DeleteLocalRef(jbundle);
- env->DeleteLocalRef(BundleClass);
-}
-
-static bool _getImage(JNIEnv *env, AMediaCodec *codec, const bool isInput, int index, AMediaImage *image) {
- jobject jimage = NULL, jrect = NULL;
- jobjectArray jplanes = NULL;
- int bottom, left, right, top;
- bool success = TRUE;
-
- jimage = (isInput) ?
- env->CallObjectMethod(codec->jcodec, codec->getInputImageMethod, index):
- env->CallObjectMethod(codec->jcodec, codec->getOutputImageMethod, index);
-
- if(handle_java_exception() == -1 || jimage == NULL) {
- LOGP(ERROR, "%s(): could not get the %s image with index [%d]", __FUNCTION__, (isInput) ? "input" : "output", index);
- success = FALSE;
- goto end;
- }
-
- image->format = env->CallIntMethod(jimage, codec->getFormatMethod);
- image->width = env->CallIntMethod(jimage, codec->getWidthMethod);
- image->height = env->CallIntMethod(jimage, codec->getHeightMethod);
- image->timestamp = env->CallLongMethod(jimage, codec->getTimestrampMethod);
-
- jrect = env->CallObjectMethod(jimage, codec->getCropRectMethod);
- if(jrect == NULL) {
- LOGP(ERROR, "%s: could not get crop rectangle", __FUNCTION__);
- success = FALSE;
- goto end;
- }
- bottom = env->GetIntField(jrect, codec->bottomField);
- left = env->GetIntField(jrect, codec->leftField);
- right = env->GetIntField(jrect, codec->rightField);
- top = env->GetIntField(jrect, codec->topField);
- image->crop_rect.x = left;
- image->crop_rect.y = top;
- image->crop_rect.w = right - left;
- image->crop_rect.h = bottom - top;
-
- jplanes = reinterpret_cast<jobjectArray>(env->CallObjectMethod(jimage, codec->getPlanesMethod));
- image->nplanes = env->GetArrayLength(jplanes);
- for(int i=0; i<image->nplanes; i++) {
- jobject jplane = env->GetObjectArrayElement(jplanes, i);
- image->pixel_strides[i] = env->CallIntMethod(jplane, codec->getPixelStrideMethod);
- if(env->ExceptionCheck()) {
- image->pixel_strides[i] = -1;
- env->ExceptionClear();
- }
- image->row_strides[i] = env->CallIntMethod(jplane, codec->getRowStrideMethod);
- if(env->ExceptionCheck()) {
- image->row_strides[i] = -1;
- env->ExceptionClear();
- }
- jobject jbuffer = env->CallObjectMethod(jplane, codec->getBufferMethod);
- image->buffers[i] = (uint8_t *)env->GetDirectBufferAddress(jbuffer);
- env->DeleteLocalRef(jbuffer);
- env->DeleteLocalRef(jplane);
- }
-
- image->priv_ptr = env->NewGlobalRef(jimage);
-
-end:
- if (jimage) env->DeleteLocalRef(jimage);
- if (jplanes) env->DeleteLocalRef(jplanes);
- if (jrect) env->DeleteLocalRef(jrect);
- return success;
-}
-
-bool AMediaCodec_getInputImage(AMediaCodec * codec, int index, AMediaImage *image) {
- JNIEnv *env = ms_get_jni_env();
- return _getImage(env, codec, TRUE, index, image);
-}
-
-bool AMediaCodec_getOutputImage(AMediaCodec *codec, int index, AMediaImage *image) {
- JNIEnv *env = ms_get_jni_env();
- return _getImage(env, codec, FALSE, index, image);
-}
-
-void AMediaImage_close(AMediaImage *image) {
- jclass imageClass = NULL;
- jmethodID close;
- bool_t success = TRUE;
-
- JNIEnv *env = ms_get_jni_env();
- jobject jimage = (jobject)image->priv_ptr;
-
- success = success && _loadClass(env, "android/media/Image", &imageClass);
- success = success && _getMethodID(env, imageClass, "close", "()V", &close);
- if (!success) {
- LOGP(ERROR, "%s: could not load some class or method ID", __FUNCTION__);
- }
- if (imageClass) {
- env->CallVoidMethod(jimage, close);
- env->DeleteLocalRef(imageClass);
- }
- env->DeleteGlobalRef(jimage);
- image->priv_ptr = NULL;
-}
-
-bool_t AMediaImage_isAvailable(void) {
- return ms_get_android_sdk_version() >= 22;
-}
-
-
-////////////////////////////////////////////////////
-// //
-// MEDIA FORMAT //
-// //
-////////////////////////////////////////////////////
-
-bool AMediaFormat_loadMethodID(AMediaFormat * format) {
- JNIEnv *env = ms_get_jni_env();
- jclass mediaFormatClass = NULL;
- jobject jformat = NULL;
- jmethodID createID = NULL;
- jstring msg = NULL;
- bool success = true;
-
- success &= _loadClass(env, "android/media/MediaFormat", &mediaFormatClass);
- if(!success) {
- LOGP(ERROR, "%s(): one class could not be found", __FUNCTION__);
- goto error;
- }
-
- success &= _getStaticMethodID(env, mediaFormatClass, "createVideoFormat", "(Ljava/lang/String;II)Landroid/media/MediaFormat;", &createID);
- success &= _getMethodID(env, mediaFormatClass, "setInteger", "(Ljava/lang/String;I)V", &(format->setInteger));
- success &= _getMethodID(env, mediaFormatClass, "getInteger", "(Ljava/lang/String;)I", &(format->getInteger));
- success &= _getMethodID(env, mediaFormatClass, "setString", "(Ljava/lang/String;Ljava/lang/String;)V", &(format->setString));
- if(!success) {
- LOGP(ERROR, "%s(): one method or field could not be found", __FUNCTION__);
- goto error;
- }
-
- msg = env->NewStringUTF("video/avc");
- jformat = env->CallStaticObjectMethod(mediaFormatClass, createID, msg, 240, 320);
- if (!jformat) {
- LOGP(ERROR, "Failed to create format !");
- goto error;
- }
-
- format->jformat = env->NewGlobalRef(jformat);
- env->DeleteLocalRef(jformat);
- env->DeleteLocalRef(mediaFormatClass);
- env->DeleteLocalRef(msg);
- return true;
-
- error:
- if (mediaFormatClass) env->DeleteLocalRef(mediaFormatClass);
- if (jformat) env->DeleteLocalRef(jformat);
- if (msg) env->DeleteLocalRef(msg);
- return false;
-}
-
-//STUB
-AMediaFormat *AMediaFormat_new(void) {
- AMediaFormat *format = ms_new0(AMediaFormat, 1);
-
- if (!AMediaFormat_loadMethodID(format)) {
- ms_free(format);
- format = NULL;
- }
- return format;
-}
-
-media_status_t AMediaFormat_delete(AMediaFormat* format) {
- JNIEnv *env = ms_get_jni_env();
-
- env->DeleteGlobalRef(format->jformat);
- ms_free(format);
-
- return AMEDIA_OK;
-}
-
-bool AMediaFormat_getInt32(AMediaFormat *format, const char *name, int32_t *out){
- JNIEnv *env = ms_get_jni_env();
-
- if (!format) {
- LOGP(ERROR, "Format nul");
- return false;
- }
-
- jstring jkey = env->NewStringUTF(name);
- jint jout = env->CallIntMethod(format->jformat, format->getInteger, jkey);
- *out = jout;
- env->DeleteLocalRef(jkey);
- handle_java_exception();
-
- return true;
-}
-
-void AMediaFormat_setInt32(AMediaFormat *format, const char* name, int32_t value) {
- JNIEnv *env = ms_get_jni_env();
- jstring jkey = env->NewStringUTF(name);
- env->CallVoidMethod(format->jformat, format->setInteger, jkey, value);
- env->DeleteLocalRef(jkey);
- handle_java_exception();
-}
-
-void AMediaFormat_setString(AMediaFormat *format, const char* key, const char* name) {
- JNIEnv *env = ms_get_jni_env();
-
- jstring jkey = env->NewStringUTF(key);
- jstring jvalue = env->NewStringUTF(name);
- env->CallVoidMethod(format->jformat, format->setString, jkey, jvalue);
- env->DeleteLocalRef(jkey);
- env->DeleteLocalRef(jvalue);
- handle_java_exception();
-}
-
-const char* AMediaFormat_toString(AMediaFormat*)
-{
- return "";
-}
diff --git a/RtspFace/mediastreamer2/src/android/android_mediacodec.h b/RtspFace/mediastreamer2/src/android/android_mediacodec.h
deleted file mode 100644
index 7308dc1..0000000
--- a/RtspFace/mediastreamer2/src/android/android_mediacodec.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-mediastreamer2 android_mediacodec.h
-Copyright (C) 2015 Belledonne Communications SARL
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#define MEDIASTREAMER2_ANDROID_MEDIACODEC
-
-typedef bool bool_t;
-
-//#include "mediastreamer2/mscommon.h"
-//#include "mediastreamer2/msvideo.h"
-typedef struct MSRect{
- int x,y,w,h;
-} MSRect;
-
-#include <media/NdkMediaCodec.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- int format;
- int width;
- int height;
- MSRect crop_rect;
- uint64_t timestamp;
- int nplanes;
- int row_strides[4];
- int pixel_strides[4];
- uint8_t *buffers[4];
- void *priv_ptr;
-} AMediaImage;
-
-void AMediaCodec_reset(AMediaCodec *codec);
-void AMediaCodec_setParams(AMediaCodec *codec, const char *params);
-bool AMediaCodec_getInputImage(AMediaCodec *codec, int index, AMediaImage *image);
-bool AMediaCodec_getOutputImage(AMediaCodec *codec, int index, AMediaImage *image);
-void AMediaImage_close(AMediaImage *image);
-bool_t AMediaImage_isAvailable(void);
-
-const char* AMediaFormat_toString(AMediaFormat*);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaCodec.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaCodec.h
deleted file mode 100644
index c07f4c9..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaCodec.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_CODEC_H
-#define _NDK_MEDIA_CODEC_H
-
-#include <android/native_window.h>
-
-#include "NdkMediaCrypto.h"
-#include "NdkMediaError.h"
-#include "NdkMediaFormat.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct AMediaCodec;
-typedef struct AMediaCodec AMediaCodec;
-
-struct AMediaCodecBufferInfo {
- int32_t offset;
- int32_t size;
- int64_t presentationTimeUs;
- uint32_t flags;
-};
-typedef struct AMediaCodecBufferInfo AMediaCodecBufferInfo;
-typedef struct AMediaCodecCryptoInfo AMediaCodecCryptoInfo;
-
-enum {
- AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM = 4,
- AMEDIACODEC_CONFIGURE_FLAG_ENCODE = 1,
- AMEDIACODEC_INFO_OUTPUT_BUFFERS_CHANGED = -3,
- AMEDIACODEC_INFO_OUTPUT_FORMAT_CHANGED = -2,
- AMEDIACODEC_INFO_TRY_AGAIN_LATER = -1
-};
-
-/**
- * Create codec by name. Use this if you know the exact codec you want to use.
- * When configuring, you will need to specify whether to use the codec as an
- * encoder or decoder.
- */
-AMediaCodec* AMediaCodec_createCodecByName(const char *name);
-
-/**
- * Create codec by mime type. Most applications will use this, specifying a
- * mime type obtained from media extractor.
- */
-AMediaCodec* AMediaCodec_createDecoderByType(const char *mime_type);
-
-/**
- * Create encoder by name.
- */
-AMediaCodec* AMediaCodec_createEncoderByType(const char *mime_type);
-
-/**
- * delete the codec and free its resources
- */
-media_status_t AMediaCodec_delete(AMediaCodec*);
-
-/**
- * Configure the codec. For decoding you would typically get the format from an extractor.
- */
-media_status_t AMediaCodec_configure(
- AMediaCodec*,
- const AMediaFormat* format,
- ANativeWindow* surface,
- AMediaCrypto *crypto,
- uint32_t flags);
-
-/**
- * Start the codec. A codec must be configured before it can be started, and must be started
- * before buffers can be sent to it.
- */
-media_status_t AMediaCodec_start(AMediaCodec*);
-
-/**
- * Stop the codec.
- */
-media_status_t AMediaCodec_stop(AMediaCodec*);
-
-/*
- * Flush the codec's input and output. All indices previously returned from calls to
- * AMediaCodec_dequeueInputBuffer and AMediaCodec_dequeueOutputBuffer become invalid.
- */
-media_status_t AMediaCodec_flush(AMediaCodec*);
-
-/**
- * Get an input buffer. The specified buffer index must have been previously obtained from
- * dequeueInputBuffer, and not yet queued.
- */
-uint8_t* AMediaCodec_getInputBuffer(AMediaCodec*, size_t idx, size_t *out_size);
-
-/**
- * Get an output buffer. The specified buffer index must have been previously obtained from
- * dequeueOutputBuffer, and not yet queued.
- */
-uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size);
-
-/**
- * Get the index of the next available input buffer. An app will typically use this with
- * getInputBuffer() to get a pointer to the buffer, then copy the data to be encoded or decoded
- * into the buffer before passing it to the codec.
- */
-ssize_t AMediaCodec_dequeueInputBuffer(AMediaCodec*, int64_t timeoutUs);
-
-/**
- * Send the specified buffer to the codec for processing.
- */
-media_status_t AMediaCodec_queueInputBuffer(AMediaCodec*,
- size_t idx, off_t offset, size_t size, uint64_t time, uint32_t flags);
-
-/**
- * Send the specified buffer to the codec for processing.
- */
-media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*,
- size_t idx, off_t offset, AMediaCodecCryptoInfo*, uint64_t time, uint32_t flags);
-
-/**
- * Get the index of the next available buffer of processed data.
- */
-ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, int64_t timeoutUs);
-AMediaFormat* AMediaCodec_getOutputFormat(AMediaCodec*);
-
-/**
- * If you are done with a buffer, use this call to return the buffer to
- * the codec. If you previously specified a surface when configuring this
- * video decoder you can optionally render the buffer.
- */
-media_status_t AMediaCodec_releaseOutputBuffer(AMediaCodec*, size_t idx, bool render);
-
-/**
- * If you are done with a buffer, use this call to update its surface timestamp
- * and return it to the codec to render it on the output surface. If you
- * have not specified an output surface when configuring this video codec,
- * this call will simply return the buffer to the codec.
- *
- * For more details, see the Java documentation for MediaCodec.releaseOutputBuffer.
- */
-media_status_t AMediaCodec_releaseOutputBufferAtTime(
- AMediaCodec *mData, size_t idx, int64_t timestampNs);
-
-
-typedef enum {
- AMEDIACODECRYPTOINFO_MODE_CLEAR = 0,
- AMEDIACODECRYPTOINFO_MODE_AES_CTR = 1
-} cryptoinfo_mode_t;
-
-/**
- * Create an AMediaCodecCryptoInfo from scratch. Use this if you need to use custom
- * crypto info, rather than one obtained from AMediaExtractor.
- *
- * AMediaCodecCryptoInfo describes the structure of an (at least
- * partially) encrypted input sample.
- * A buffer's data is considered to be partitioned into "subsamples",
- * each subsample starts with a (potentially empty) run of plain,
- * unencrypted bytes followed by a (also potentially empty) run of
- * encrypted bytes.
- * numBytesOfClearData can be null to indicate that all data is encrypted.
- * This information encapsulates per-sample metadata as outlined in
- * ISO/IEC FDIS 23001-7:2011 "Common encryption in ISO base media file format files".
- */
-AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new(
- int numsubsamples,
- uint8_t key[16],
- uint8_t iv[16],
- cryptoinfo_mode_t mode,
- size_t *clearbytes,
- size_t *encryptedbytes);
-
-/**
- * delete an AMediaCodecCryptoInfo created previously with AMediaCodecCryptoInfo_new, or
- * obtained from AMediaExtractor
- */
-media_status_t AMediaCodecCryptoInfo_delete(AMediaCodecCryptoInfo*);
-
-/**
- * The number of subsamples that make up the buffer's contents.
- */
-size_t AMediaCodecCryptoInfo_getNumSubSamples(AMediaCodecCryptoInfo*);
-
-/**
- * A 16-byte opaque key
- */
-media_status_t AMediaCodecCryptoInfo_getKey(AMediaCodecCryptoInfo*, uint8_t *dst);
-
-/**
- * A 16-byte initialization vector
- */
-media_status_t AMediaCodecCryptoInfo_getIV(AMediaCodecCryptoInfo*, uint8_t *dst);
-
-/**
- * The type of encryption that has been applied,
- * one of AMEDIACODECRYPTOINFO_MODE_CLEAR or AMEDIACODECRYPTOINFO_MODE_AES_CTR.
- */
-cryptoinfo_mode_t AMediaCodecCryptoInfo_getMode(AMediaCodecCryptoInfo*);
-
-/**
- * The number of leading unencrypted bytes in each subsample.
- */
-media_status_t AMediaCodecCryptoInfo_getClearBytes(AMediaCodecCryptoInfo*, size_t *dst);
-
-/**
- * The number of trailing encrypted bytes in each subsample.
- */
-media_status_t AMediaCodecCryptoInfo_getEncryptedBytes(AMediaCodecCryptoInfo*, size_t *dst);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif //_NDK_MEDIA_CODEC_H
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaCrypto.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaCrypto.h
deleted file mode 100644
index 90374c5..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaCrypto.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_CRYPTO_H
-#define _NDK_MEDIA_CRYPTO_H
-
-#include <sys/types.h>
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct AMediaCrypto;
-typedef struct AMediaCrypto AMediaCrypto;
-
-typedef uint8_t AMediaUUID[16];
-
-bool AMediaCrypto_isCryptoSchemeSupported(const AMediaUUID uuid);
-
-bool AMediaCrypto_requiresSecureDecoderComponent(const char *mime);
-
-AMediaCrypto* AMediaCrypto_new(const AMediaUUID uuid, const void *initData, size_t initDataSize);
-
-void AMediaCrypto_delete(AMediaCrypto* crypto);
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _NDK_MEDIA_CRYPTO_H
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaDrm.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaDrm.h
deleted file mode 100644
index 10afdd9..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaDrm.h
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_DRM_H
-#define _NDK_MEDIA_DRM_H
-
-#include "NdkMediaError.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-#include <stdbool.h>
-
-struct AMediaDrm;
-typedef struct AMediaDrm AMediaDrm;
-
-typedef struct {
- const uint8_t *ptr;
- size_t length;
-} AMediaDrmByteArray;
-
-typedef AMediaDrmByteArray AMediaDrmSessionId;
-typedef AMediaDrmByteArray AMediaDrmScope;
-typedef AMediaDrmByteArray AMediaDrmKeySetId;
-typedef AMediaDrmByteArray AMediaDrmSecureStop;
-
-
-typedef enum AMediaDrmEventType {
- /**
- * This event type indicates that the app needs to request a certificate from
- * the provisioning server. The request message data is obtained using
- * AMediaDrm_getProvisionRequest.
- */
- EVENT_PROVISION_REQUIRED = 1,
-
- /**
- * This event type indicates that the app needs to request keys from a license
- * server. The request message data is obtained using AMediaDrm_getKeyRequest.
- */
- EVENT_KEY_REQUIRED = 2,
-
- /**
- * This event type indicates that the licensed usage duration for keys in a session
- * has expired. The keys are no longer valid.
- */
- EVENT_KEY_EXPIRED = 3,
-
- /**
- * This event may indicate some specific vendor-defined condition, see your
- * DRM provider documentation for details
- */
- EVENT_VENDOR_DEFINED = 4
-} AMediaDrmEventType;
-
-typedef void (*AMediaDrmEventListener)(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- AMediaDrmEventType eventType, int extra, const uint8_t *data, size_t dataSize);
-
-
-/**
- * Query if the given scheme identified by its UUID is supported on this device, and
- * whether the drm plugin is able to handle the media container format specified by mimeType.
- *
- * uuid identifies the universal unique ID of the crypto scheme. uuid must be 16 bytes.
- * mimeType is the MIME type of the media container, e.g. "video/mp4". If mimeType
- * is not known or required, it can be provided as NULL.
- */
-bool AMediaDrm_isCryptoSchemeSupported(const uint8_t *uuid, const char *mimeType);
-
-/**
- * Create a MediaDrm instance from a UUID
- * uuid identifies the universal unique ID of the crypto scheme. uuid must be 16 bytes.
- */
-AMediaDrm* AMediaDrm_createByUUID(const uint8_t *uuid);
-
-/**
- * Release a MediaDrm object
- */
-void AMediaDrm_release(AMediaDrm *);
-
-/**
- * Register a callback to be invoked when an event occurs
- *
- * listener is the callback that will be invoked on event
- */
-media_status_t AMediaDrm_setOnEventListener(AMediaDrm *, AMediaDrmEventListener listener);
-
-/**
- * Open a new session with the MediaDrm object. A session ID is returned.
- *
- * returns MEDIADRM_NOT_PROVISIONED_ERROR if provisioning is needed
- * returns MEDIADRM_RESOURCE_BUSY_ERROR if required resources are in use
- */
-media_status_t AMediaDrm_openSession(AMediaDrm *, AMediaDrmSessionId *sessionId);
-
-/**
- * Close a session on the MediaDrm object that was previously opened
- * with AMediaDrm_openSession.
- */
-media_status_t AMediaDrm_closeSession(AMediaDrm *, const AMediaDrmSessionId *sessionId);
-
-typedef enum AMediaDrmKeyType {
- /**
- * This key request type species that the keys will be for online use, they will
- * not be saved to the device for subsequent use when the device is not connected
- * to a network.
- */
- KEY_TYPE_STREAMING = 1,
-
- /**
- * This key request type specifies that the keys will be for offline use, they
- * will be saved to the device for use when the device is not connected to a network.
- */
- KEY_TYPE_OFFLINE = 2,
-
- /**
- * This key request type specifies that previously saved offline keys should be released.
- */
- KEY_TYPE_RELEASE = 3
-} AMediaDrmKeyType;
-
-/**
- * Data type containing {key, value} pair
- */
-typedef struct AMediaDrmKeyValuePair {
- const char *mKey;
- const char *mValue;
-} AMediaDrmKeyValue;
-
-/**
- * A key request/response exchange occurs between the app and a license server
- * to obtain or release keys used to decrypt encrypted content.
- * AMediaDrm_getKeyRequest is used to obtain an opaque key request byte array that
- * is delivered to the license server. The opaque key request byte array is
- * returned in KeyRequest.data. The recommended URL to deliver the key request to
- * is returned in KeyRequest.defaultUrl.
- *
- * After the app has received the key request response from the server,
- * it should deliver to the response to the DRM engine plugin using the method
- * AMediaDrm_provideKeyResponse.
- *
- * scope may be a sessionId or a keySetId, depending on the specified keyType.
- * When the keyType is KEY_TYPE_STREAMING or KEY_TYPE_OFFLINE, scope should be set
- * to the sessionId the keys will be provided to. When the keyType is
- * KEY_TYPE_RELEASE, scope should be set to the keySetId of the keys being released.
- * Releasing keys from a device invalidates them for all sessions.
- *
- * init container-specific data, its meaning is interpreted based on the mime type
- * provided in the mimeType parameter. It could contain, for example, the content
- * ID, key ID or other data obtained from the content metadata that is required in
- * generating the key request. init may be null when keyType is KEY_TYPE_RELEASE.
- *
- * initSize is the number of bytes of initData
- *
- * mimeType identifies the mime type of the content.
- *
- * keyType specifes the type of the request. The request may be to acquire keys for
- * streaming or offline content, or to release previously acquired keys, which are
- * identified by a keySetId.
- *
- * optionalParameters are included in the key request message to allow a client
- * application to provide additional message parameters to the server.
- *
- * numOptionalParameters indicates the number of optional parameters provided
- * by the caller
- *
- * On exit:
- * 1. The keyRequest pointer will reference the opaque key request data. It
- * will reside in memory owned by the AMediaDrm object, and will remain
- * accessible until the next call to AMediaDrm_getKeyRequest or until the
- * MediaDrm object is released.
- * 2. keyRequestSize will be set to the size of the request
- *
- * returns MEDIADRM_NOT_PROVISIONED_ERROR if reprovisioning is needed, due to a
- * problem with the device certificate.
-*/
-media_status_t AMediaDrm_getKeyRequest(AMediaDrm *, const AMediaDrmScope *scope,
- const uint8_t *init, size_t initSize, const char *mimeType, AMediaDrmKeyType keyType,
- const AMediaDrmKeyValue *optionalParameters, size_t numOptionalParameters,
- const uint8_t **keyRequest, size_t *keyRequestSize);
-
-/**
- * A key response is received from the license server by the app, then it is
- * provided to the DRM engine plugin using provideKeyResponse. When the
- * response is for an offline key request, a keySetId is returned that can be
- * used to later restore the keys to a new session with AMediaDrm_restoreKeys.
- * When the response is for a streaming or release request, a null keySetId is
- * returned.
- *
- * scope may be a sessionId or keySetId depending on the type of the
- * response. Scope should be set to the sessionId when the response is for either
- * streaming or offline key requests. Scope should be set to the keySetId when
- * the response is for a release request.
- *
- * response points to the opaque response from the server
- * responseSize should be set to the size of the response in bytes
- */
-
-media_status_t AMediaDrm_provideKeyResponse(AMediaDrm *, const AMediaDrmScope *scope,
- const uint8_t *response, size_t responseSize, AMediaDrmKeySetId *keySetId);
-
-/**
- * Restore persisted offline keys into a new session. keySetId identifies the
- * keys to load, obtained from a prior call to AMediaDrm_provideKeyResponse.
- *
- * sessionId is the session ID for the DRM session
- * keySetId identifies the saved key set to restore
- */
-media_status_t AMediaDrm_restoreKeys(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- const AMediaDrmKeySetId *keySetId);
-
-/**
- * Remove the current keys from a session.
- *
- * keySetId identifies keys to remove
- */
-media_status_t AMediaDrm_removeKeys(AMediaDrm *, const AMediaDrmSessionId *keySetId);
-
-/**
- * Request an informative description of the key status for the session. The status is
- * in the form of {key, value} pairs. Since DRM license policies vary by vendor,
- * the specific status field names are determined by each DRM vendor. Refer to your
- * DRM provider documentation for definitions of the field names for a particular
- * DRM engine plugin.
- *
- * On entry, numPairs should be set by the caller to the maximum number of pairs
- * that can be returned (the size of the array). On exit, numPairs will be set
- * to the number of entries written to the array. If the number of {key, value} pairs
- * to be returned is greater than *numPairs, MEDIADRM_SHORT_BUFFER will be returned
- * and numPairs will be set to the number of pairs available.
- */
-media_status_t AMediaDrm_queryKeyStatus(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- AMediaDrmKeyValue *keyValuePairs, size_t *numPairs);
-
-
-/**
- * A provision request/response exchange occurs between the app and a provisioning
- * server to retrieve a device certificate. If provisionining is required, the
- * EVENT_PROVISION_REQUIRED event will be sent to the event handler.
- * getProvisionRequest is used to obtain the opaque provision request byte array that
- * should be delivered to the provisioning server.
- * On exit:
- * 1. The provision request data will be referenced by provisionRequest, in
- * memory owned by the AMediaDrm object. It will remain accessible until the
- * next call to getProvisionRequest.
- * 2. provisionRequestSize will be set to the size of the request data.
- * 3. serverUrl will reference a NULL terminated string containing the URL
- * the provisioning request should be sent to. It will remain accessible until
- * the next call to getProvisionRequest.
- */
-media_status_t AMediaDrm_getProvisionRequest(AMediaDrm *, const uint8_t **provisionRequest,
- size_t *provisionRequestSize, const char **serverUrl);
-
-
-/**
- * After a provision response is received by the app, it is provided to the DRM
- * engine plugin using this method.
- *
- * response is the opaque provisioning response byte array to provide to the
- * DRM engine plugin.
- * responseSize is the length of the provisioning response in bytes.
- *
- * returns MEDIADRM_DEVICE_REVOKED_ERROR if the response indicates that the
- * server rejected the request
- */
-media_status_t AMediaDrm_provideProvisionResponse(AMediaDrm *,
- const uint8_t *response, size_t responseSize);
-
-
-/**
- * A means of enforcing limits on the number of concurrent streams per subscriber
- * across devices is provided via SecureStop. This is achieved by securely
- * monitoring the lifetime of sessions.
- *
- * Information from the server related to the current playback session is written
- * to persistent storage on the device when each MediaCrypto object is created.
- *
- * In the normal case, playback will be completed, the session destroyed and the
- * Secure Stops will be queried. The app queries secure stops and forwards the
- * secure stop message to the server which verifies the signature and notifies the
- * server side database that the session destruction has been confirmed. The persisted
- * record on the client is only removed after positive confirmation that the server
- * received the message using releaseSecureStops().
- *
- * numSecureStops is set by the caller to the maximum number of secure stops to
- * return. On exit, *numSecureStops will be set to the number actually returned.
- * If *numSecureStops is too small for the number of secure stops available,
- * MEDIADRM_SHORT_BUFFER will be returned and *numSecureStops will be set to the
- * number required.
- */
-media_status_t AMediaDrm_getSecureStops(AMediaDrm *,
- AMediaDrmSecureStop *secureStops, size_t *numSecureStops);
-
-/**
- * Process the SecureStop server response message ssRelease. After authenticating
- * the message, remove the SecureStops identified in the response.
- *
- * ssRelease is the server response indicating which secure stops to release
- */
-media_status_t AMediaDrm_releaseSecureStops(AMediaDrm *,
- const AMediaDrmSecureStop *ssRelease);
-
-/**
- * String property name: identifies the maker of the DRM engine plugin
- */
-const char *PROPERTY_VENDOR = "vendor";
-
-/**
- * String property name: identifies the version of the DRM engine plugin
- */
-const char *PROPERTY_VERSION = "version";
-
-/**
- * String property name: describes the DRM engine plugin
- */
-const char *PROPERTY_DESCRIPTION = "description";
-
-/**
- * String property name: a comma-separated list of cipher and mac algorithms
- * supported by CryptoSession. The list may be empty if the DRM engine
- * plugin does not support CryptoSession operations.
- */
-const char *PROPERTY_ALGORITHMS = "algorithms";
-
-/**
- * Read a DRM engine plugin String property value, given the property name string.
- *
- * propertyName identifies the property to query
- * On return, propertyValue will be set to point to the property value. The
- * memory that the value resides in is owned by the NDK MediaDrm API and
- * will remain valid until the next call to AMediaDrm_getPropertyString.
- */
-media_status_t AMediaDrm_getPropertyString(AMediaDrm *, const char *propertyName,
- const char **propertyValue);
-
-/**
- * Byte array property name: the device unique identifier is established during
- * device provisioning and provides a means of uniquely identifying each device.
- */
-const char *PROPERTY_DEVICE_UNIQUE_ID = "deviceUniqueId";
-
-/**
- * Read a DRM engine plugin byte array property value, given the property name string.
- * On return, *propertyValue will be set to point to the property value. The
- * memory that the value resides in is owned by the NDK MediaDrm API and
- * will remain valid until the next call to AMediaDrm_getPropertyByteArray.
- */
-media_status_t AMediaDrm_getPropertyByteArray(AMediaDrm *, const char *propertyName,
- AMediaDrmByteArray *propertyValue);
-
-/**
- * Set a DRM engine plugin String property value.
- */
-media_status_t AMediaDrm_setPropertyString(AMediaDrm *, const char *propertyName,
- const char *value);
-
-/**
- * Set a DRM engine plugin byte array property value.
- */
-media_status_t AMediaDrm_setPropertyByteArray(AMediaDrm *, const char *propertyName,
- const uint8_t *value, size_t valueSize);
-
-/**
- * In addition to supporting decryption of DASH Common Encrypted Media, the
- * MediaDrm APIs provide the ability to securely deliver session keys from
- * an operator's session key server to a client device, based on the factory-installed
- * root of trust, and then perform encrypt, decrypt, sign and verify operations
- * with the session key on arbitrary user data.
- *
- * Operators create session key servers that receive session key requests and provide
- * encrypted session keys which can be used for general purpose crypto operations.
- *
- * Generic encrypt/decrypt/sign/verify methods are based on the established session
- * keys. These keys are exchanged using the getKeyRequest/provideKeyResponse methods.
- *
- * Applications of this capability include securing various types of purchased or
- * private content, such as applications, books and other media, photos or media
- * delivery protocols.
- */
-
-/*
- * Encrypt the data referenced by input of length dataSize using algorithm specified
- * by cipherAlgorithm, and write the encrypted result into output. The caller must
- * ensure that the output buffer is large enough to accept dataSize bytes. The key
- * to use is identified by the 16 byte keyId. The key must have been loaded into
- * the session using provideKeyResponse.
- */
-media_status_t AMediaDrm_encrypt(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- const char *cipherAlgorithm, uint8_t *keyId, uint8_t *iv,
- const uint8_t *input, uint8_t *output, size_t dataSize);
-
-/*
- * Decrypt the data referenced by input of length dataSize using algorithm specified
- * by cipherAlgorithm, and write the decrypted result into output. The caller must
- * ensure that the output buffer is large enough to accept dataSize bytes. The key
- * to use is identified by the 16 byte keyId. The key must have been loaded into
- * the session using provideKeyResponse.
- */
-media_status_t AMediaDrm_decrypt(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- const char *cipherAlgorithm, uint8_t *keyId, uint8_t *iv,
- const uint8_t *input, uint8_t *output, size_t dataSize);
-
-/*
- * Generate a signature using the specified macAlgorithm over the message data
- * referenced by message of size messageSize and store the signature in the
- * buffer referenced signature of max size *signatureSize. If the buffer is not
- * large enough to hold the signature, MEDIADRM_SHORT_BUFFER is returned and
- * *signatureSize is set to the buffer size required. The key to use is identified
- * by the 16 byte keyId. The key must have been loaded into the session using
- * provideKeyResponse.
- */
-media_status_t AMediaDrm_sign(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- const char *macAlgorithm, uint8_t *keyId, uint8_t *message, size_t messageSize,
- uint8_t *signature, size_t *signatureSize);
-
-/*
- * Perform a signature verification using the specified macAlgorithm over the message
- * data referenced by the message parameter of size messageSize. Returns MEDIADRM_OK
- * if the signature matches, otherwise MEDAIDRM_VERIFY_FAILED is returned. The key to
- * use is identified by the 16 byte keyId. The key must have been loaded into the
- * session using provideKeyResponse.
- */
-media_status_t AMediaDrm_verify(AMediaDrm *, const AMediaDrmSessionId *sessionId,
- const char *macAlgorithm, uint8_t *keyId, const uint8_t *message, size_t messageSize,
- const uint8_t *signature, size_t signatureSize);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif //_NDK_MEDIA_DRM_H
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaError.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaError.h
deleted file mode 100644
index 12613eb..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaError.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_ERROR_H
-#define _NDK_MEDIA_ERROR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- AMEDIA_OK = 0,
-
- AMEDIA_ERROR_BASE = -10000,
- AMEDIA_ERROR_UNKNOWN = AMEDIA_ERROR_BASE,
- AMEDIA_ERROR_MALFORMED = AMEDIA_ERROR_BASE - 1,
- AMEDIA_ERROR_UNSUPPORTED = AMEDIA_ERROR_BASE - 2,
- AMEDIA_ERROR_INVALID_OBJECT = AMEDIA_ERROR_BASE - 3,
- AMEDIA_ERROR_INVALID_PARAMETER = AMEDIA_ERROR_BASE - 4,
-
- AMEDIA_DRM_ERROR_BASE = -20000,
- AMEDIA_DRM_NOT_PROVISIONED = AMEDIA_DRM_ERROR_BASE - 1,
- AMEDIA_DRM_RESOURCE_BUSY = AMEDIA_DRM_ERROR_BASE - 2,
- AMEDIA_DRM_DEVICE_REVOKED = AMEDIA_DRM_ERROR_BASE - 3,
- AMEDIA_DRM_SHORT_BUFFER = AMEDIA_DRM_ERROR_BASE - 4,
- AMEDIA_DRM_SESSION_NOT_OPENED = AMEDIA_DRM_ERROR_BASE - 5,
- AMEDIA_DRM_TAMPER_DETECTED = AMEDIA_DRM_ERROR_BASE - 6,
- AMEDIA_DRM_VERIFY_FAILED = AMEDIA_DRM_ERROR_BASE - 7,
- AMEDIA_DRM_NEED_KEY = AMEDIA_DRM_ERROR_BASE - 8,
- AMEDIA_DRM_LICENSE_EXPIRED = AMEDIA_DRM_ERROR_BASE - 9,
-
-} media_status_t;
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _NDK_MEDIA_ERROR_H
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaExtractor.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaExtractor.h
deleted file mode 100644
index 7a4e702..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaExtractor.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_EXTRACTOR_H
-#define _NDK_MEDIA_EXTRACTOR_H
-
-#include <sys/types.h>
-
-#include "NdkMediaCodec.h"
-#include "NdkMediaFormat.h"
-#include "NdkMediaCrypto.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct AMediaExtractor;
-typedef struct AMediaExtractor AMediaExtractor;
-
-
-/**
- * Create new media extractor
- */
-AMediaExtractor* AMediaExtractor_new();
-
-/**
- * Delete a previously created media extractor
- */
-media_status_t AMediaExtractor_delete(AMediaExtractor*);
-
-/**
- * Set the file descriptor from which the extractor will read.
- */
-media_status_t AMediaExtractor_setDataSourceFd(AMediaExtractor*, int fd, off64_t offset, off64_t length);
-
-/**
- * Set the URI from which the extractor will read.
- */
-media_status_t AMediaExtractor_setDataSource(AMediaExtractor*, const char *location); // TODO support headers
-
-/**
- * Return the number of tracks in the previously specified media file
- */
-size_t AMediaExtractor_getTrackCount(AMediaExtractor*);
-
-/**
- * Return the format of the specified track. The caller must free the returned format
- */
-AMediaFormat* AMediaExtractor_getTrackFormat(AMediaExtractor*, size_t idx);
-
-/**
- * Select the specified track. Subsequent calls to readSampleData, getSampleTrackIndex and
- * getSampleTime only retrieve information for the subset of tracks selected.
- * Selecting the same track multiple times has no effect, the track is
- * only selected once.
- */
-media_status_t AMediaExtractor_selectTrack(AMediaExtractor*, size_t idx);
-
-/**
- * Unselect the specified track. Subsequent calls to readSampleData, getSampleTrackIndex and
- * getSampleTime only retrieve information for the subset of tracks selected..
- */
-media_status_t AMediaExtractor_unselectTrack(AMediaExtractor*, size_t idx);
-
-/**
- * Read the current sample.
- */
-ssize_t AMediaExtractor_readSampleData(AMediaExtractor*, uint8_t *buffer, size_t capacity);
-
-/**
- * Read the current sample's flags.
- */
-uint32_t AMediaExtractor_getSampleFlags(AMediaExtractor*); // see definitions below
-
-/**
- * Returns the track index the current sample originates from (or -1
- * if no more samples are available)
- */
-int AMediaExtractor_getSampleTrackIndex(AMediaExtractor*);
-
-/**
- * Returns the current sample's presentation time in microseconds.
- * or -1 if no more samples are available.
- */
-int64_t AMediaExtractor_getSampleTime(AMediaExtractor*);
-
-/**
- * Advance to the next sample. Returns false if no more sample data
- * is available (end of stream).
- */
-bool AMediaExtractor_advance(AMediaExtractor*);
-
-typedef enum {
- AMEDIAEXTRACTOR_SEEK_PREVIOUS_SYNC,
- AMEDIAEXTRACTOR_SEEK_NEXT_SYNC,
- AMEDIAEXTRACTOR_SEEK_CLOSEST_SYNC
-} SeekMode;
-
-/**
- *
- */
-media_status_t AMediaExtractor_seekTo(AMediaExtractor*, int64_t seekPosUs, SeekMode mode);
-
-/**
- * mapping of crypto scheme uuid to the scheme specific data for that scheme
- */
-typedef struct PsshEntry {
- AMediaUUID uuid;
- size_t datalen;
- void *data;
-} PsshEntry;
-
-/**
- * list of crypto schemes and their data
- */
-typedef struct PsshInfo {
- size_t numentries;
- PsshEntry entries[0];
-} PsshInfo;
-
-/**
- * Get the PSSH info if present.
- */
-PsshInfo* AMediaExtractor_getPsshInfo(AMediaExtractor*);
-
-
-AMediaCodecCryptoInfo *AMediaExtractor_getSampleCryptoInfo(AMediaExtractor *);
-
-
-enum {
- AMEDIAEXTRACTOR_SAMPLE_FLAG_SYNC = 1,
- AMEDIAEXTRACTOR_SAMPLE_FLAG_ENCRYPTED = 2,
-};
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _NDK_MEDIA_EXTRACTOR_H
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaFormat.cpp b/RtspFace/mediastreamer2/src/android/media/NdkMediaFormat.cpp
deleted file mode 100644
index 794414f..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaFormat.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "NdkMediaFormat.h"
-#define EXPORT
-
-EXPORT const char* AMEDIAFORMAT_KEY_AAC_PROFILE = "aac-profile";
-EXPORT const char* AMEDIAFORMAT_KEY_BIT_RATE = "bitrate";
-EXPORT const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT = "channel-count";
-EXPORT const char* AMEDIAFORMAT_KEY_CHANNEL_MASK = "channel-mask";
-EXPORT const char* AMEDIAFORMAT_KEY_COLOR_FORMAT = "color-format";
-EXPORT const char* AMEDIAFORMAT_KEY_DURATION = "durationUs";
-EXPORT const char* AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL = "flac-compression-level";
-EXPORT const char* AMEDIAFORMAT_KEY_FRAME_RATE = "frame-rate";
-EXPORT const char* AMEDIAFORMAT_KEY_HEIGHT = "height";
-EXPORT const char* AMEDIAFORMAT_KEY_IS_ADTS = "is-adts";
-EXPORT const char* AMEDIAFORMAT_KEY_IS_AUTOSELECT = "is-autoselect";
-EXPORT const char* AMEDIAFORMAT_KEY_IS_DEFAULT = "is-default";
-EXPORT const char* AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE = "is-forced-subtitle";
-EXPORT const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL = "i-frame-interval";
-EXPORT const char* AMEDIAFORMAT_KEY_LANGUAGE = "language";
-EXPORT const char* AMEDIAFORMAT_KEY_MAX_HEIGHT = "max-height";
-EXPORT const char* AMEDIAFORMAT_KEY_MAX_INPUT_SIZE = "max-input-size";
-EXPORT const char* AMEDIAFORMAT_KEY_MAX_WIDTH = "max-width";
-EXPORT const char* AMEDIAFORMAT_KEY_MIME = "mime";
-EXPORT const char* AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP = "push-blank-buffers-on-shutdown";
-EXPORT const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER = "repeat-previous-frame-after";
-EXPORT const char* AMEDIAFORMAT_KEY_SAMPLE_RATE = "sample-rate";
-EXPORT const char* AMEDIAFORMAT_KEY_WIDTH = "width";
-EXPORT const char* AMEDIAFORMAT_KEY_STRIDE = "stride";
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaFormat.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaFormat.h
deleted file mode 100644
index b313dd2..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaFormat.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_FORMAT_H
-#define _NDK_MEDIA_FORMAT_H
-
-#include <sys/types.h>
-
-#include "NdkMediaError.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct AMediaFormat;
-typedef struct AMediaFormat AMediaFormat;
-
-AMediaFormat *AMediaFormat_new(void);
-media_status_t AMediaFormat_delete(AMediaFormat*);
-
-/**
- * Human readable representation of the format. The returned string is owned by the format,
- * and remains valid until the next call to toString, or until the format is deleted.
- */
-const char* AMediaFormat_toString(AMediaFormat*);
-
-bool AMediaFormat_getInt32(AMediaFormat*, const char *name, int32_t *out);
-bool AMediaFormat_getInt64(AMediaFormat*, const char *name, int64_t *out);
-bool AMediaFormat_getFloat(AMediaFormat*, const char *name, float *out);
-/**
- * The returned data is owned by the format and remains valid as long as the named entry
- * is part of the format.
- */
-bool AMediaFormat_getBuffer(AMediaFormat*, const char *name, void** data, size_t *size);
-/**
- * The returned string is owned by the format, and remains valid until the next call to getString,
- * or until the format is deleted.
- */
-bool AMediaFormat_getString(AMediaFormat*, const char *name, const char **out);
-
-
-void AMediaFormat_setInt32(AMediaFormat*, const char* name, int32_t value);
-void AMediaFormat_setInt64(AMediaFormat*, const char* name, int64_t value);
-void AMediaFormat_setFloat(AMediaFormat*, const char* name, float value);
-/**
- * The provided string is copied into the format.
- */
-void AMediaFormat_setString(AMediaFormat*, const char* name, const char* value);
-/**
- * The provided data is copied into the format.
- */
-void AMediaFormat_setBuffer(AMediaFormat*, const char* name, void* data, size_t size);
-
-
-
-/**
- * XXX should these be ints/enums that we look up in a table as needed?
- */
-extern const char* AMEDIAFORMAT_KEY_AAC_PROFILE;
-extern const char* AMEDIAFORMAT_KEY_BIT_RATE;
-extern const char* AMEDIAFORMAT_KEY_CHANNEL_COUNT;
-extern const char* AMEDIAFORMAT_KEY_CHANNEL_MASK;
-extern const char* AMEDIAFORMAT_KEY_COLOR_FORMAT;
-extern const char* AMEDIAFORMAT_KEY_DURATION;
-extern const char* AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL;
-extern const char* AMEDIAFORMAT_KEY_FRAME_RATE;
-extern const char* AMEDIAFORMAT_KEY_HEIGHT;
-extern const char* AMEDIAFORMAT_KEY_IS_ADTS;
-extern const char* AMEDIAFORMAT_KEY_IS_AUTOSELECT;
-extern const char* AMEDIAFORMAT_KEY_IS_DEFAULT;
-extern const char* AMEDIAFORMAT_KEY_IS_FORCED_SUBTITLE;
-extern const char* AMEDIAFORMAT_KEY_I_FRAME_INTERVAL;
-extern const char* AMEDIAFORMAT_KEY_LANGUAGE;
-extern const char* AMEDIAFORMAT_KEY_MAX_HEIGHT;
-extern const char* AMEDIAFORMAT_KEY_MAX_INPUT_SIZE;
-extern const char* AMEDIAFORMAT_KEY_MAX_WIDTH;
-extern const char* AMEDIAFORMAT_KEY_MIME;
-extern const char* AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP;
-extern const char* AMEDIAFORMAT_KEY_REPEAT_PREVIOUS_FRAME_AFTER;
-extern const char* AMEDIAFORMAT_KEY_SAMPLE_RATE;
-extern const char* AMEDIAFORMAT_KEY_WIDTH;
-extern const char* AMEDIAFORMAT_KEY_STRIDE;
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _NDK_MEDIA_FORMAT_H
diff --git a/RtspFace/mediastreamer2/src/android/media/NdkMediaMuxer.h b/RtspFace/mediastreamer2/src/android/media/NdkMediaMuxer.h
deleted file mode 100644
index 90d946c..0000000
--- a/RtspFace/mediastreamer2/src/android/media/NdkMediaMuxer.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * This file defines an NDK API.
- * Do not remove methods.
- * Do not change method signatures.
- * Do not change the value of constants.
- * Do not change the size of any of the classes defined in here.
- * Do not reference types that are not part of the NDK.
- * Do not #include files that aren't part of the NDK.
- */
-
-#ifndef _NDK_MEDIA_MUXER_H
-#define _NDK_MEDIA_MUXER_H
-
-#include <sys/types.h>
-
-#include "NdkMediaCodec.h"
-#include "NdkMediaError.h"
-#include "NdkMediaFormat.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct AMediaMuxer;
-typedef struct AMediaMuxer AMediaMuxer;
-
-typedef enum {
- AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4 = 0,
- AMEDIAMUXER_OUTPUT_FORMAT_WEBM = 1,
-} OutputFormat;
-
-/**
- * Create new media muxer
- */
-AMediaMuxer* AMediaMuxer_new(int fd, OutputFormat format);
-
-/**
- * Delete a previously created media muxer
- */
-media_status_t AMediaMuxer_delete(AMediaMuxer*);
-
-/**
- * Set and store the geodata (latitude and longitude) in the output file.
- * This method should be called before AMediaMuxer_start. The geodata is stored
- * in udta box if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, and is
- * ignored for other output formats.
- * The geodata is stored according to ISO-6709 standard.
- *
- * Both values are specified in degrees.
- * Latitude must be in the range [-90, 90].
- * Longitude must be in the range [-180, 180].
- */
-media_status_t AMediaMuxer_setLocation(AMediaMuxer*, float latitude, float longitude);
-
-/**
- * Sets the orientation hint for output video playback.
- * This method should be called before AMediaMuxer_start. Calling this
- * method will not rotate the video frame when muxer is generating the file,
- * but add a composition matrix containing the rotation angle in the output
- * video if the output format is AMEDIAMUXER_OUTPUT_FORMAT_MPEG_4, so that a
- * video player can choose the proper orientation for playback.
- * Note that some video players may choose to ignore the composition matrix
- * during playback.
- * The angle is specified in degrees, clockwise.
- * The supported angles are 0, 90, 180, and 270 degrees.
- */
-media_status_t AMediaMuxer_setOrientationHint(AMediaMuxer*, int degrees);
-
-/**
- * Adds a track with the specified format.
- * Returns the index of the new track or a negative value in case of failure,
- * which can be interpreted as a media_status_t.
- */
-ssize_t AMediaMuxer_addTrack(AMediaMuxer*, const AMediaFormat* format);
-
-/**
- * Start the muxer. Should be called after AMediaMuxer_addTrack and
- * before AMediaMuxer_writeSampleData.
- */
-media_status_t AMediaMuxer_start(AMediaMuxer*);
-
-/**
- * Stops the muxer.
- * Once the muxer stops, it can not be restarted.
- */
-media_status_t AMediaMuxer_stop(AMediaMuxer*);
-
-/**
- * Writes an encoded sample into the muxer.
- * The application needs to make sure that the samples are written into
- * the right tracks. Also, it needs to make sure the samples for each track
- * are written in chronological order (e.g. in the order they are provided
- * by the encoder.)
- */
-media_status_t AMediaMuxer_writeSampleData(AMediaMuxer *muxer,
- size_t trackIdx, const uint8_t *data, const AMediaCodecBufferInfo *info);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _NDK_MEDIA_MUXER_H
diff --git a/RtspFace/mediastreamer2/src/android/media/README.txt b/RtspFace/mediastreamer2/src/android/media/README.txt
deleted file mode 100644
index f0030cd..0000000
--- a/RtspFace/mediastreamer2/src/android/media/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-This folder contains files header from android ndk. It's used for compile with older version of android 6 to uses mediacodec functions.
-
diff --git a/RtspFace/mediastreamer2/src/utils/msjava.c.cpp b/RtspFace/mediastreamer2/src/utils/msjava.c.cpp
deleted file mode 100644
index d32ba66..0000000
--- a/RtspFace/mediastreamer2/src/utils/msjava.c.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-mediastreamer2 library - modular sound and video processing and streaming
-Copyright (C) 2010 Belledonne Communications SARL
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include "mediastreamer2/msjava.h"
-//#include "mediastreamer2/mscommon.h"
-#include "../../logger.h"
-
-static JavaVM *ms2_vm=NULL;
-
-#ifndef _WIN32
-#include <pthread.h>
-
-static pthread_key_t jnienv_key;
-
-/*
- * Do not forget that any log within this routine may cause re-attach of the thread to the jvm because the logs can callback the java application
- * (see LinphoneCoreFactory.setLogHandler() ).
-**/
-void _android_key_cleanup(void *data){
- JNIEnv *env = (JNIEnv*) data;
-
- if (env != NULL) {
- LOGP(INFO, "Thread end, detaching jvm from current thread");
- ms2_vm->DetachCurrentThread();
- pthread_setspecific(jnienv_key,NULL);
- }
-}
-#endif
-
-void ms_set_jvm_from_env(JNIEnv *env){
- env->GetJavaVM(&ms2_vm);
-#ifndef _WIN32
- pthread_key_create(&jnienv_key,_android_key_cleanup);
-#endif
-}
-
-void ms_set_jvm(JavaVM *vm){
- ms2_vm=vm;
-#ifndef _WIN32
- pthread_key_create(&jnienv_key,_android_key_cleanup);
-#endif
-}
-
-JavaVM *ms_get_jvm(void){
- return ms2_vm;
-}
-
-JNIEnv *ms_get_jni_env(void){
- JNIEnv *env=NULL;
- if (ms2_vm==NULL){
- LOGP(ERROR, "Calling ms_get_jni_env() while no jvm has been set using ms_set_jvm().");
- }else{
-#ifndef _WIN32
- env=(JNIEnv*)pthread_getspecific(jnienv_key);
- if (env==NULL){
- if (ms2_vm->AttachCurrentThread(&env,NULL)!=0){
- LOGP(ERROR, "AttachCurrentThread() failed !");
- return NULL;
- }
- pthread_setspecific(jnienv_key,env);
- }
-#else
- LOGP(ERROR, "ms_get_jni_env() not implemented on windows.");
-#endif
- }
- return env;
-}
-
-#ifdef __ANDROID__
-
-int ms_get_android_sdk_version(void) {
- static int sdk_version = 0;
- if (sdk_version==0){
- /* Get Android SDK version. */
- JNIEnv *env = ms_get_jni_env();
- jclass version_class = env->FindClass("android/os/Build$VERSION");
- jfieldID fid = env->GetStaticFieldID(version_class, "SDK_INT", "I");
- sdk_version = env->GetStaticIntField(version_class, fid);
- LOGP(INFO, "SDK version [%i] detected", sdk_version);
- env->DeleteLocalRef(version_class);
- }
- return sdk_version;
-}
-
-JNIEXPORT void JNICALL Java_org_linphone_mediastream_Log_d(JNIEnv* env, jobject thiz, jstring jmsg) {
- const char* msg = jmsg ? env->GetStringUTFChars(jmsg, NULL) : NULL;
- LOGP(DEBUG, "%s", msg);
- if (msg) env->ReleaseStringUTFChars(jmsg, msg);
-}
-
-JNIEXPORT void JNICALL Java_org_linphone_mediastream_Log_i(JNIEnv* env, jobject thiz, jstring jmsg) {
- const char* msg = jmsg ? env->GetStringUTFChars(jmsg, NULL) : NULL;
- LOGP(INFO, "%s", msg);
- if (msg) env->ReleaseStringUTFChars(jmsg, msg);
-}
-
-JNIEXPORT void JNICALL Java_org_linphone_mediastream_Log_w(JNIEnv* env, jobject thiz, jstring jmsg) {
- const char* msg = jmsg ? env->GetStringUTFChars(jmsg, NULL) : NULL;
- LOGP(WARNING, "%s", msg);
- if (msg) env->ReleaseStringUTFChars(jmsg, msg);
-}
-
-JNIEXPORT void JNICALL Java_org_linphone_mediastream_Log_e(JNIEnv* env, jobject thiz, jstring jmsg) {
- const char* msg = jmsg ? env->GetStringUTFChars(jmsg, NULL) : NULL;
- LOGP(ERROR, "%s", msg);
- if (msg) env->ReleaseStringUTFChars(jmsg, msg);
-}
-
-#endif
--
Gitblit v1.8.0