#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmp4box_write.h"
#include "jnixmp4.h"
#include <android/log.h>
#define TAG "xmp4" // 这个是自定义的LOG的标识
#define LOG(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) // 定义LOGD类型
static AFMP4Handle s_mHandle = NULL;
static const char *s_pFilename = NULL;
static unsigned long m_curVideoTimeStamp=0;
static unsigned long m_curAudioTimeStamp=0;
JNIEXPORT jint JNICALL
Java_Studio_Core_XLinkService_CDK_XMP4boxOpen(JNIEnv* env, jobject jobt, jstring filename, jint mode)
{
if (s_pFilename)
{
free(s_pFilename);
s_pFilename = 0;
}
const char *pFilename = (*env)->GetStringUTFChars(env, filename, 0);
LOG("%s:%d", pFilename, mode);
s_mHandle = MP4WriterInit();
s_pFilename = malloc(strlen(pFilename)+1);
strcpy(s_pFilename, pFilename);
(*env)->ReleaseStringUTFChars(env, filename, pFilename);
return s_mHandle == NULL ? -1 : 0;
}
JNIEXPORT jint JNICALL
Java_Studio_Core_XLinkService_CDK_XMP4boxClose(JNIEnv* env, jobject jobt)
{
if (s_pFilename)
{
free(s_pFilename);
s_pFilename = 0;
}
if (s_mHandle)
{
MP4WriterSaveFile(s_mHandle);
MP4WriterExit(s_mHandle);
}
return 0;
}
JNIEXPORT jint JNICALL
Java_Studio_Core_XLinkService_CDK_XMP4boxSetVideoParam(JNIEnv* env, jobject jobt, jint type, jint width, jint height, jint frameRate)
{
if (s_mHandle == 0 || s_pFilename==0)
{
return -1;
}
m_curVideoTimeStamp = 0;
m_curAudioTimeStamp = 0;
MP4WriterCreateFile(s_mHandle, s_pFilename, type, width, height, frameRate);
return 0;
}
JNIEXPORT jint JNICALL
Java_Studio_Core_XLinkService_CDK_XMP4boxWriteData(JNIEnv* env, jobject jobt, jint type, jbyteArray pBuffer, jint bufferSize, jint bKey, jlong nTimeStamp)
{
if (s_mHandle == NULL)
{
return -1;
}
char *p_InBuffer = (char*)(*env)->GetByteArrayElements(env, pBuffer, 0);
if (type == 0) //音频
{
//return XMP4_RECWriteAudioData(s_mHandle, p_InBuffer, bufferSize);
}
else if (type == 1) //视频
{
return MP4WriterWriteFile(s_mHandle, p_InBuffer, bufferSize, bKey, nTimeStamp);
}
return 0;
}
JNIEXPORT jint JNICALL
Java_Studio_Core_XLinkService_CDK_XMP4RECReadData(JNIEnv* env, jobject jobt, jint type, jbyteArray pOutBuffer, jintArray nFrameType)
{
if (s_mHandle == NULL)
{
return -1;
}
//char *p_InBuffer = (char*)(*env)->GetByteArrayElements(env, pOutBuffer, 0);
//int blen = (*env)->GetArrayLength(env, pOutBuffer);
//char *pBuf = (char*)malloc(blen);
//int nBufLen = 0;
//int nType = 0;
//if (type == 0) //音频
//{
// XMP4_RECReadAudioData(s_mHandle, pBuf, &nBufLen, &nType);
//}
//else if (type == 1) //视频
//{
// XMP4_RECReadVideoData(s_mHandle, pBuf, &nBufLen, &nType);
//}
//if (nBufLen)
//{
// jbyte *jByte = (jbyte*)(pBuf);
// (*env)->SetByteArrayRegion(env, pOutBuffer, 0, nBufLen, jByte);
// jint type[1];
// type[0] = (jint)nType;
// (*env)->SetIntArrayRegion(env, nFrameType, 0, 1, type);
//}
//free(pBuf);
//return nBufLen;
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
libmp4box.zip (178个子文件)
libstdc++.a 8B
libstdc++.a 8B
jnixmp4.c 3KB
libmp4box_write.cpp 14KB
libmp4box_write.o.d 10KB
libmp4box_write.o.d 10KB
jnixmp4.o.d 8KB
jnixmp4.o.d 8KB
isomedia.h 127KB
isomedia_dev.h 92KB
nodes_mpeg4.h 89KB
mpeg4_odf.h 53KB
nodes_x3d.h 53KB
compositor_dev.h 49KB
terminal_dev.h 46KB
ietf.h 43KB
media_tools.h 40KB
mpegts.h 37KB
maths.h 35KB
scenegraph_dev.h 34KB
tools.h 33KB
service.h 29KB
dash.h 27KB
bifs_tables.h 26KB
scenegraph.h 26KB
constants.h 23KB
events_constants.h 22KB
scenegraph_vrml.h 22KB
download.h 21KB
odf_dev.h 20KB
svg_types.h 20KB
scenegraph_svg.h 19KB
path2d.h 19KB
bitstream.h 16KB
scene_manager.h 16KB
network.h 15KB
dsmcc.h 15KB
media_dev.h 15KB
codec.h 14KB
avilib.h 14KB
mpd.h 13KB
nodes_svg.h 13KB
smjs_api.h 12KB
color.h 12KB
html5_media.h 12KB
module.h 12KB
setup.h 12KB
mesh.h 11KB
options.h 11KB
terminal.h 11KB
ietf_dev.h 10KB
avparse.h 10KB
raster2d.h 10KB
mediaobject.h 10KB
xml.h 10KB
events.h 9KB
video_out.h 9KB
swf_dev.h 9KB
laser_dev.h 8KB
compositor.h 8KB
thread.h 8KB
scene_engine.h 8KB
config_file.h 8KB
dvb_mpe_dev.h 8KB
cache.h 8KB
bifs_dev.h 8KB
html5_mse.h 8KB
audio_out.h 7KB
ogg.h 7KB
crypt.h 7KB
term_info.h 7KB
configuration.h 7KB
list.h 6KB
rtp_streamer.h 6KB
ismacryp.h 6KB
camera.h 5KB
esi.h 5KB
ait.h 5KB
map.h 5KB
bifs.h 4KB
sync_layer.h 4KB
filestreamer.h 4KB
crypt_dev.h 4KB
m3u8.h 4KB
user.h 4KB
token.h 4KB
font.h 4KB
laser.h 3KB
ipmp.h 3KB
utf.h 3KB
base_coding.h 3KB
ringbuffer.h 3KB
term_ext.h 3KB
jnixmp4.h 3KB
webvtt.h 3KB
odf_parse_common.h 2KB
iso639.h 2KB
js_usr.h 2KB
reedsolomon.h 2KB
vobsub.h 2KB
共 178 条
- 1
- 2
资源评论
- 缔峰泽科技2020-07-22花了钱,没有示例 没有java文件,只有一个平台,还要自己弄,不好用,。
c710347136
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功