本文整理汇总了C++中MediaMetadataRetriever::setDataSource方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaMetadataRetriever::setDataSource方法的具体用法?C++ MediaMetadataRetriever::setDataSource怎么用?C++ MediaMetadataRetriever::setDataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaMetadataRetriever
的用法示例。
在下文中一共展示了MediaMetadataRetriever::setDataSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wseemann_media_FFmpegMediaMetadataRetriever_setDataSourceFD
static void wseemann_media_FFmpegMediaMetadataRetriever_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length)
{
__android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, "setDataSource");
MediaMetadataRetriever* retriever = getRetriever(env, thiz);
if (retriever == 0) {
jniThrowException(env, "java/lang/IllegalStateException", "No retriever available");
return;
}
if (!fileDescriptor) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (offset < 0 || length < 0 || fd < 0) {
if (offset < 0) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "negative offset (%lld)", offset);
}
if (length < 0) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "negative length (%lld)", length);
}
if (fd < 0) {
__android_log_write(ANDROID_LOG_ERROR, LOG_TAG, "invalid file descriptor");
}
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
process_media_retriever_call(env, retriever->setDataSource(fd, offset, length), "java/lang/RuntimeException", "setDataSource failed");
}
开发者ID:Leetyle,项目名称:FFmpegMediaMetadataRetriever,代码行数:28,代码来源:wseemann_media_MediaMetadataRetriever.cpp
示例2: android_media_MediaMetadataRetriever_setDataSourceFD
static void android_media_MediaMetadataRetriever_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length)
{
ALOGV("setDataSource Fd");
MediaMetadataRetriever* retriever = getRetriever(env, thiz);
if (retriever == 0) {
jniThrowException(env, "java/lang/IllegalStateException", "No retriever available");
return;
}
if (!fileDescriptor) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (offset < 0 || length < 0 || fd < 0) {
if (offset < 0) {
ALOGE("negative offset (%lld)", offset);
}
if (length < 0) {
ALOGE("negative length (%lld)", length);
}
if (fd < 0) {
ALOGE("invalid file descriptor");
}
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
process_media_retriever_call(env, retriever->setDataSource(fd, offset, length), "java/lang/RuntimeException", "setDataSource failed");
}
示例3: pathStr
static void
android_media_MediaMetadataRetriever_setDataSourceAndHeaders(
JNIEnv *env, jobject thiz, jstring path,
jobjectArray keys, jobjectArray values) {
ALOGV("setDataSource Path");
MediaMetadataRetriever* retriever = getRetriever(env, thiz);
if (retriever == 0) {
jniThrowException(
env,
"java/lang/IllegalStateException", "No retriever available");
return;
}
if (!path) {
jniThrowException(
env, "java/lang/IllegalArgumentException", "Null pointer");
return;
}
const char *tmp = env->GetStringUTFChars(path, NULL);
if (!tmp) { // OutOfMemoryError exception already thrown
return;
}
String8 pathStr(tmp);
env->ReleaseStringUTFChars(path, tmp);
tmp = NULL;
// Don't let somebody trick us in to reading some random block of memory
if (strncmp("mem://", pathStr.string(), 6) == 0) {
jniThrowException(
env, "java/lang/IllegalArgumentException", "Invalid pathname");
return;
}
// We build a similar KeyedVector out of it.
KeyedVector<String8, String8> headersVector;
if (!ConvertKeyValueArraysToKeyedVector(
env, keys, values, &headersVector)) {
return;
}
process_media_retriever_call(
env,
retriever->setDataSource(
pathStr.string(), headersVector.size() > 0 ? &headersVector : NULL),
"java/lang/RuntimeException",
"setDataSource failed");
}
示例4: getRetriever
static void
wseemann_media_FFmpegMediaMetadataRetriever_setDataSourceAndHeaders(
JNIEnv *env, jobject thiz, jstring path,
jobjectArray keys, jobjectArray values) {
__android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, "setDataSource");
MediaMetadataRetriever* retriever = getRetriever(env, thiz);
if (retriever == 0) {
jniThrowException(env, "java/lang/IllegalStateException", "No retriever available");
return;
}
if (!path) {
jniThrowException(env, "java/lang/IllegalArgumentException", "Null pointer");
return;
}
const char *tmp = env->GetStringUTFChars(path, NULL);
if (!tmp) { // OutOfMemoryError exception already thrown
return;
}
// Don't let somebody trick us in to reading some random block of memory
if (strncmp("mem://", tmp, 6) == 0) {
jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid pathname");
return;
}
// Workaround for FFmpeg ticket #998
// "must convert mms://... streams to mmsh://... for FFmpeg to work"
char *restrict_to = strstr(tmp, "mms://");
if (restrict_to) {
strncpy(restrict_to, "mmsh://", 6);
puts(tmp);
}
char *headers = NULL;
if (keys && values != NULL) {
int keysCount = env->GetArrayLength(keys);
int valuesCount = env->GetArrayLength(values);
if (keysCount != valuesCount) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "keys and values arrays have different length");
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
int i = 0;
const char *rawString = NULL;
char hdrs[2048];
for (i = 0; i < keysCount; i++) {
jstring key = (jstring) env->GetObjectArrayElement(keys, i);
rawString = env->GetStringUTFChars(key, NULL);
strcat(hdrs, rawString);
strcat(hdrs, ": ");
env->ReleaseStringUTFChars(key, rawString);
jstring value = (jstring) env->GetObjectArrayElement(values, i);
rawString = env->GetStringUTFChars(value, NULL);
strcat(hdrs, rawString);
strcat(hdrs, "\r\n");
env->ReleaseStringUTFChars(value, rawString);
}
headers = &hdrs[0];
}
process_media_retriever_call(
env,
retriever->setDataSource(tmp, headers),
"java/lang/IllegalArgumentException",
"setDataSource failed");
env->ReleaseStringUTFChars(path, tmp);
tmp = NULL;
}
开发者ID:Leetyle,项目名称:FFmpegMediaMetadataRetriever,代码行数:78,代码来源:wseemann_media_MediaMetadataRetriever.cpp