include/mm_file_format_amr.h \
include/mm_file_format_imelody.h \
include/mm_file_format_midi.h \
- include/mm_file_format_ffmpeg_mem.h \
include/mm_file_format_ffmpeg.h \
include/mm_file_format_mmf.h \
#include/mm_file_format_mp3.h \
libmmfile_formats_la_SOURCES = mm_file_formats.c \
mm_file_format_dummy.c \
mm_file_format_ffmpeg.c \
- mm_file_format_ffmpeg_mem.c \
mm_file_format_mp3.c \
mm_file_format_aac.c \
mm_file_format_mmf.c \
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * 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.
- *
- */
-
-#ifndef _MM_FILE_PLUGIN_FFMPEG_MEM_H_
-#define _MM_FILE_PLUGIN_FFMPEG_MEM_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <libavformat/avformat.h>
-#include <libavformat/url.h>
-
-extern URLProtocol MMFileMEMProtocol;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MM_FILE_PLUGIN_FFMPEG_H_ */
#include <stdlib.h>
#include <libavformat/avformat.h>
-#include <libavformat/url.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <mm_error.h>
#include "mm_file_formats.h"
#include "mm_file_utils.h"
#include "mm_file_format_ffmpeg.h"
-#include "mm_file_format_ffmpeg_mem.h"
#include <sys/time.h>
#define _SHORT_MEDIA_LIMIT 2000 /* under X seconds duration*/
int mmfile_format_close_ffmpg(MMFileFormatContext *formatContext);
static int getMimeType(int formatId, char *mimeType, int buf_size);
+static int _mmf_mem_read(void *opaque, uint8_t *buf, int size);
+static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence);
+typedef struct {
+ unsigned char *ptr;
+ long long size;
+ long long offset;
+ int state;
+} MMFmemIOHandle;
+
+static int _mmf_mem_open(MMFmemIOHandle **handle, const char *filename)
+{
+ MMFmemIOHandle *memHandle = NULL;
+ char **splitedString = NULL;
+
+ filename += strlen(MMFILE_MEM_URI);
+
+ splitedString = mmfile_strsplit(filename, ":");
+ if (splitedString == NULL) {
+ debug_error(DEBUG, "invalid param\n");
+ return MMFILE_IO_FAILED;
+ }
+
+ if (!splitedString[0] || !splitedString[1]) {
+ debug_error(DEBUG, "invalid param\n");
+ goto exception;
+ }
+
+ memHandle = mmfile_malloc(sizeof(MMFmemIOHandle));
+ if (!memHandle) {
+ debug_error(DEBUG, "error: mmfile_malloc memHandle\n");
+ goto exception;
+ }
+
+ memHandle->ptr = (unsigned char *)atoll(splitedString[0]); /*memory allocation address changed. memHandle->ptr = (unsigned char*)atoi(splitedString[0]); */
+ memHandle->size = atoi(splitedString[1]);
+ memHandle->offset = 0;
+ memHandle->state = 0;
+
+ *handle = memHandle;
+
+ if (splitedString) {
+ mmfile_strfreev(splitedString);
+ }
+
+ return MMFILE_IO_SUCCESS;
+
+exception:
+
+ if (splitedString) {
+ mmfile_strfreev(splitedString);
+ }
+
+ return MMFILE_IO_FAILED;
+}
+
+static int _mmf_mem_read(void *opaque, uint8_t *buf, int size)
+{
+ MMFmemIOHandle *memHandle = NULL;
+ const unsigned char *c = NULL;
+ int len = 0;
+
+ if (!opaque || !buf) {
+ debug_error(DEBUG, "invalid para\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ memHandle = opaque;
+
+ if (!memHandle->ptr) {
+ debug_error(DEBUG, "invalid para\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ if (memHandle->offset >= memHandle->size) {
+ /* for some file formats last file read */
+ debug_error(DEBUG, "File Read is beyond the file Size\n");
+ return MMFILE_UTIL_FAIL;
+
+ }
+
+ c = memHandle->ptr + memHandle->offset;
+
+ if (memHandle->state != EOF) {
+ len = size;
+ if (len + memHandle->offset > memHandle->size) {
+ len = memHandle->size - memHandle->offset;
+ }
+ }
+
+ memcpy(buf, c, len);
+
+ memHandle->offset += len;
+
+ if (memHandle->offset == memHandle->size) {
+ memHandle->state = EOF;
+ }
+
+ return len;
+}
+
+static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence)
+{
+ MMFmemIOHandle *memHandle = NULL;
+ long long tmp_offset = 0;
+
+ if (!opaque) {
+ debug_error(DEBUG, "invalid para\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ memHandle = opaque;
+
+ switch (whence) {
+ case SEEK_SET:
+ tmp_offset = 0 + pos;
+ break;
+ case SEEK_CUR:
+ tmp_offset = memHandle->offset + pos;
+ break;
+ case SEEK_END:
+ tmp_offset = memHandle->size + pos;
+ break;
+ case AVSEEK_SIZE: /*FFMPEG specific*/
+ return memHandle->size;
+ default:
+ return MMFILE_UTIL_FAIL;
+ }
+
+ /*check validation*/
+ if (tmp_offset < 0 && tmp_offset > memHandle->size) {
+ debug_error(DEBUG, "invalid file offset\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ /*set */
+ memHandle->state = (tmp_offset >= memHandle->size) ? EOF : !EOF;
+ memHandle->offset = (unsigned int) tmp_offset;
+
+ return tmp_offset;
+}
EXPORT_API
int mmfile_format_open_ffmpg(MMFileFormatContext *formatContext)
unsigned int i;
char ffmpegFormatName[MMFILE_FILE_FMT_MAX_LEN] = {0, };
char mimeType[MMFILE_MIMETYPE_MAX_LEN] = {0, };
+ AVIOContext *pIOCtx = NULL;
+ MMFmemIOHandle *handle = NULL;
+ uint8_t *avio_ctx_buffer = NULL;
formatContext->ReadStream = mmfile_format_read_stream_ffmpg;
formatContext->ReadFrame = mmfile_format_read_frame_ffmpg;
av_register_all();
if (formatContext->filesrc->type == MM_FILE_SRC_TYPE_MEMORY) {
-
- ffurl_register_protocol(&MMFileMEMProtocol);
-
if (getMimeType(formatContext->filesrc->memory.format, mimeType, MMFILE_MIMETYPE_MAX_LEN) < 0) {
debug_error(DEBUG, "error: Error in MIME Type finding\n");
return MMFILE_FORMAT_FAIL;
goto exception;
}
- ret = avformat_open_input(&pFormatCtx, formatContext->uriFileName, grab_iformat, NULL);
+ avio_ctx_buffer = av_malloc(MMFILE_AVIO_BUFFER_LEN);
+ if (avio_ctx_buffer == NULL) {
+ debug_error(DEBUG, "error: cannot alloc avio_ctx_buffert\n");
+ goto exception;
+ }
+
+ ret = _mmf_mem_open(&handle, formatContext->uriFileName);
+ if (ret != MMFILE_IO_SUCCESS) {
+ debug_warning(DEBUG, "failed to _mmf_mem_open.\n");
+ goto exception;
+ }
+
+ pIOCtx = avio_alloc_context(avio_ctx_buffer, MMFILE_AVIO_BUFFER_LEN, 0, handle, _mmf_mem_read, NULL, _mmf_mem_seek);
+ if (pIOCtx == NULL) {
+ debug_error(DEBUG, "error: cannot alloc io context\n");
+ goto exception;
+ }
+
+ pFormatCtx = avformat_alloc_context();
+ if (pFormatCtx == NULL) {
+ debug_warning(DEBUG, "failed to avformat_alloc_context\n");
+ goto exception;
+ }
+
+ pFormatCtx->pb = pIOCtx;
+
+ ret = avformat_open_input(&pFormatCtx, "", grab_iformat, NULL);
if (ret < 0) {
debug_error(DEBUG, "error: cannot open %s %d\n", formatContext->uriFileName, ret);
goto exception;
}
+
formatContext->privateFormatData = pFormatCtx;
}
return MMFILE_FORMAT_SUCCESS;
exception: /* fail to get content information */
+ if (formatContext->filesrc->type == MM_FILE_SRC_TYPE_MEMORY) {
+ if (avio_ctx_buffer)
+ av_free(avio_ctx_buffer);
+ if (handle)
+ mmfile_free(handle);
+ if (pIOCtx)
+ av_free(pIOCtx);
+ if (pFormatCtx)
+ avformat_close_input(&pFormatCtx);
+ } else {
+ mmfile_format_close_ffmpg(formatContext);
+ }
- mmfile_format_close_ffmpg(formatContext);
formatContext->privateFormatData = NULL;
return MMFILE_FORMAT_FAIL;
avformat_close_input(&pFormatCtx);
formatContext->privateFormatData = NULL;
}
-
- if (formatContext->filesrc->type == MM_FILE_SRC_TYPE_MEMORY) {
- ffurl_deregister_protocol(&MMFileMEMProtocol);
- }
}
return MMFILE_FORMAT_SUCCESS;
if (frame->key_frame) {
debug_msg(RELEASE, "key frame!\n");
#ifdef MMFILE_FORMAT_DEBUG_DUMP
- sprintf(pgm_name, "./key_%d_%d_%d.pgm", retry, i, v);
+ memset(pgm_name, 0x00, sizeof(pgm_name));
+ snprintf(pgm_name, sizeof(pgm_name), "./key_%d_%d_%d.pgm", retry, i, v);
_save_pgm(frame->data[0], frame->linesize[0], pCodecCtx->width, pCodecCtx->height, pgm_name);
#endif
} else {
debug_msg(RELEASE, "skip (not key frame).\n");
#ifdef MMFILE_FORMAT_DEBUG_DUMP
- sprintf(pgm_name, "./not_key_%d_%d_%d.pgm", retry, i, v);
+ memset(pgm_name, 0x00, sizeof(pgm_name));
+ snprintf(pgm_name, sizeof(pgm_name), "./not_key_%d_%d_%d.pgm", retry, i, v);
_save_pgm(frame->data[0], frame->linesize[0], pCodecCtx->width, pCodecCtx->height, pgm_name);
#endif
}
+++ /dev/null
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <libavformat/avformat.h>
-#include <libavformat/avio.h>
-#include "mm_file_debug.h"
-#include "mm_file_utils.h"
-#include "mm_file_format_ffmpeg_mem.h"
-
-
-typedef struct {
- unsigned char *ptr;
- long long size;
- long long offset;
- int state;
-} MMFmemIOHandle;
-
-static int mmf_mem_open(URLContext *handle, const char *filename, int flags)
-{
- MMFmemIOHandle *memHandle = NULL;
- char **splitedString = NULL;
-
-
- if (!handle || !filename || !handle->prot) {
- debug_error(DEBUG, "invalid param\n");
- return MMFILE_UTIL_FAIL;
- }
-
- filename += strlen(handle->prot->name) + 3; /* ://%d:%d means (memory addr:mem size)*/
-
- splitedString = mmfile_strsplit(filename, ":");
- if (splitedString == NULL) {
- debug_error(DEBUG, "invalid param\n");
- return MMFILE_UTIL_FAIL;
- }
-
- if (!splitedString[0] || !splitedString[1])
-
- {
- debug_error(DEBUG, "invalid param\n");
- goto exception;
- }
-
- memHandle = mmfile_malloc(sizeof(MMFmemIOHandle));
- if (!memHandle) {
- debug_error(DEBUG, "error: mmfile_malloc memHandle\n");
- goto exception;
- }
-
- memHandle->ptr = (unsigned char *)atoll(splitedString[0]); /*memory allocation address changed. memHandle->ptr = (unsigned char *) atoi(splitedString[0]); */
- memHandle->size = atoi(splitedString[1]);
- memHandle->offset = 0;
- memHandle->state = 0;
-
- handle->priv_data = (void *) memHandle;
-
- /* Imp to reset them otherwise file seek will fail */
- handle->is_streamed = 0; /*FALSE*/
- handle->max_packet_size = 0;
-
- if (splitedString) {
- mmfile_strfreev(splitedString);
- }
-
- return MMFILE_UTIL_SUCCESS;
-
-exception:
-
- if (splitedString) {
- mmfile_strfreev(splitedString);
- }
-
-#if 0 /*dead code */
- if (memHandle) {
- mmfile_free(memHandle);
- handle->priv_data = NULL;
- }
-#endif
-
- return MMFILE_UTIL_FAIL;
-}
-
-static int mmf_mem_read(URLContext *h, unsigned char *buf, int size)
-{
- MMFmemIOHandle *memHandle = NULL;
- const unsigned char *c = NULL;
- int len = 0;
-
-
- if (!h || !h->priv_data || !buf || size <= 0) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
-
- memHandle = h->priv_data;
-
- if (!memHandle->ptr) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
-
- if (memHandle->offset >= memHandle->size) {
- /* for some file formats last file read */
- debug_error(DEBUG, "File Read is beyond the file Size\n");
- return MMFILE_UTIL_FAIL;
-
- }
-
- c = memHandle->ptr + memHandle->offset;
-
- if (memHandle->state != EOF) {
- len = size;
- if (len + memHandle->offset > memHandle->size) {
- len = memHandle->size - memHandle->offset;
- }
- }
-
- memcpy(buf, c, len);
-
- memHandle->offset += len;
-
- if (memHandle->offset == memHandle->size) {
- memHandle->state = EOF;
- }
-
- return len;
-}
-
-static int mmf_mem_write(URLContext *h, const unsigned char *buf, int size)
-{
- if (!h || !h->priv_data || !buf) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
-
- debug_error(DEBUG, "NOTE PERMITTED\n");
- return MMFILE_UTIL_FAIL;
-}
-
-
-static int64_t mmf_mem_seek(URLContext *h, int64_t pos, int whence)
-{
- MMFmemIOHandle *memHandle = NULL;
- long long tmp_offset = 0;
-
-
- if (!h || !h->priv_data) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
-
- memHandle = h->priv_data;
-
- switch (whence) {
- case SEEK_SET:
- tmp_offset = 0 + pos;
- break;
- case SEEK_CUR:
- tmp_offset = memHandle->offset + pos;
- break;
- case SEEK_END:
- tmp_offset = memHandle->size + pos;
- break;
- case AVSEEK_SIZE: /*FFMPEG specific*/
- return memHandle->size;
- default:
- return MMFILE_UTIL_FAIL;
- }
-
- /*check validation*/
- if (tmp_offset < 0 && tmp_offset > memHandle->size) {
- debug_error(DEBUG, "invalid file offset\n");
- return MMFILE_UTIL_FAIL;
- }
-
- /*set */
- memHandle->state = (tmp_offset >= memHandle->size) ? EOF : !EOF;
- memHandle->offset = (unsigned int) tmp_offset;
-
- return tmp_offset;
-}
-
-static int mmf_mem_close(URLContext *h)
-{
- MMFmemIOHandle *memHandle = NULL;
-
- if (!h || !h->priv_data) {
- debug_error(DEBUG, "invalid para\n");
- return MMFILE_UTIL_FAIL;
- }
-
- memHandle = h->priv_data;
-
- if (memHandle) {
- mmfile_free(memHandle);
- h->priv_data = NULL;
- }
-
- return MMFILE_UTIL_SUCCESS;
-}
-
-
-URLProtocol MMFileMEMProtocol = {
- .name = "mem",
- .url_open = mmf_mem_open,
- .url_read = mmf_mem_read,
- .url_write = mmf_mem_write,
- .url_seek = mmf_mem_seek,
- .url_close = mmf_mem_close,
-};
#include "mm_file_debug.h"
#include "mm_file_formats.h"
#include "mm_file_utils.h"
-#include "mm_file_format_ffmpeg_mem.h"
#include "mm_file_format_frame.h"
#define MILLION 1000000
void __save_frame(AVFrame *pFrame, int width, int height, int iFrame)
{
FILE *pFile;
- char szFilename[32];
- int y;
+ char szFilename[32] = {0,};
+ int y = 0;
/* Open file */
- sprintf(szFilename, "frame%d.ppm", iFrame);
+
+ memset(szFilename, 0x00, sizeof(szFilename));
+ snprintf(szFilename, sizeof(szFilename), "frame%d.ppm", iFrame);
pFile = fopen(szFilename, "wb");
if (pFile == NULL)
return;
}
#endif
+static int _mmf_mem_read(void *opaque, uint8_t *buf, int size);
+static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence);
+
+typedef struct {
+ unsigned char *ptr;
+ long long size;
+ long long offset;
+ int state;
+} MMFmemIOHandle;
+
+static int _mmf_mem_open(MMFmemIOHandle **handle, const char *filename)
+{
+ MMFmemIOHandle *memHandle = NULL;
+ char **splitedString = NULL;
+
+ filename += strlen(MMFILE_MEM_URI);
+
+ splitedString = mmfile_strsplit(filename, ":");
+ if (splitedString == NULL) {
+ debug_error(DEBUG, "invalid param\n");
+ return MMFILE_IO_FAILED;
+ }
+
+ if (!splitedString[0] || !splitedString[1]) {
+ debug_error(DEBUG, "invalid param\n");
+ goto exception;
+ }
+
+ memHandle = mmfile_malloc(sizeof(MMFmemIOHandle));
+ if (!memHandle) {
+ debug_error(DEBUG, "error: mmfile_malloc memHandle\n");
+ goto exception;
+ }
+
+ memHandle->ptr = (unsigned char *)atoll(splitedString[0]); /*memory allocation address changed. memHandle->ptr = (unsigned char*)atoi(splitedString[0]); */
+ memHandle->size = atoi(splitedString[1]);
+ memHandle->offset = 0;
+ memHandle->state = 0;
+
+ *handle = memHandle;
+
+ if (splitedString) {
+ mmfile_strfreev(splitedString);
+ }
+
+ return MMFILE_IO_SUCCESS;
+
+exception:
+
+ if (splitedString) {
+ mmfile_strfreev(splitedString);
+ }
+
+ return MMFILE_IO_FAILED;
+}
+
+static int _mmf_mem_read(void *opaque, uint8_t *buf, int size)
+{
+ MMFmemIOHandle *memHandle = NULL;
+ const unsigned char *c = NULL;
+ int len = 0;
+
+ if (!opaque || !buf) {
+ debug_error(DEBUG, "invalid para\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ memHandle = opaque;
+
+ if (!memHandle->ptr) {
+ debug_error(DEBUG, "invalid para\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ if (memHandle->offset >= memHandle->size) {
+ /* for some file formats last file read */
+ debug_error(DEBUG, "File Read is beyond the file Size\n");
+ return MMFILE_UTIL_FAIL;
+
+ }
+
+ c = memHandle->ptr + memHandle->offset;
+
+ if (memHandle->state != EOF) {
+ len = size;
+ if (len + memHandle->offset > memHandle->size) {
+ len = memHandle->size - memHandle->offset;
+ }
+ }
+
+ memcpy(buf, c, len);
+
+ memHandle->offset += len;
+
+ if (memHandle->offset == memHandle->size) {
+ memHandle->state = EOF;
+ }
+
+ return len;
+}
+
+static int64_t _mmf_mem_seek(void *opaque, int64_t pos, int whence)
+{
+ MMFmemIOHandle *memHandle = NULL;
+ long long tmp_offset = 0;
+
+ if (!opaque) {
+ debug_error(DEBUG, "invalid para\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ memHandle = opaque;
+
+ switch (whence) {
+ case SEEK_SET:
+ tmp_offset = 0 + pos;
+ break;
+ case SEEK_CUR:
+ tmp_offset = memHandle->offset + pos;
+ break;
+ case SEEK_END:
+ tmp_offset = memHandle->size + pos;
+ break;
+ case AVSEEK_SIZE: /*FFMPEG specific*/
+ return memHandle->size;
+ default:
+ return MMFILE_UTIL_FAIL;
+ }
+
+ /*check validation*/
+ if (tmp_offset < 0 && tmp_offset > memHandle->size) {
+ debug_error(DEBUG, "invalid file offset\n");
+ return MMFILE_UTIL_FAIL;
+ }
+
+ /*set */
+ memHandle->state = (tmp_offset >= memHandle->size) ? EOF : !EOF;
+ memHandle->offset = (unsigned int) tmp_offset;
+
+ return tmp_offset;
+}
+
static int __getMimeType(int formatId, char *mimeType, int buf_size)
{
int ret = 0; /*default: success*/
static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bool is_accurate, unsigned char **frame, int *size, int *width, int *height)
{
-
unsigned int i = 0;
int len = 0;
int ret = MMFILE_FORMAT_SUCCESS;
char *urifilename = NULL;
AVFormatContext *pFormatCtx = NULL;
AVInputFormat *grab_iformat = NULL;
+ AVIOContext *pIOCtx = NULL;
+ MMFmemIOHandle *handle = NULL;
+ uint8_t *avio_ctx_buffer = NULL;
if (!size || !width || !height) {
return MMFILE_FORMAT_FAIL;
return MMFILE_FORMAT_FAIL;
}
- ffurl_register_protocol(&MMFileMEMProtocol);
-
if (__getMimeType(format, mimeType, MMFILE_MIMETYPE_MAX_LEN) < 0) {
debug_error(DEBUG, "error: Error in MIME Type finding\n");
return MMFILE_FORMAT_FAIL;
if (NULL == grab_iformat) {
debug_error(DEBUG, "error: cannot find format\n");
+ ret = MMFILE_FORMAT_FAIL;
goto exception;
}
- ret = avformat_open_input(&pFormatCtx, urifilename, grab_iformat, NULL);
- if (ret < 0) {
- debug_error(DEBUG, "error: cannot open %s %d\n", urifilename, ret);
+ avio_ctx_buffer = av_malloc(MMFILE_AVIO_BUFFER_LEN);
+ if (avio_ctx_buffer == NULL) {
+ debug_error(DEBUG, "error: cannot alloc avio_ctx_buffert\n");
+ ret = MMFILE_FORMAT_FAIL;
goto exception;
}
+ ret = _mmf_mem_open(&handle, urifilename);
+ if (ret !=MMFILE_IO_SUCCESS) {
+ debug_warning(DEBUG, "failed to _mmf_mem_open.\n");
+ av_free(avio_ctx_buffer);
+ ret = MMFILE_FORMAT_FAIL;
+ goto exception;
+ }
+
+ pIOCtx = avio_alloc_context(avio_ctx_buffer, MMFILE_AVIO_BUFFER_LEN, 0, handle, _mmf_mem_read, NULL, _mmf_mem_seek);
+ if (pIOCtx == NULL) {
+ debug_error(DEBUG, "error: cannot alloc io context\n");
+ av_free(avio_ctx_buffer);
+ mmfile_free(handle);
+ ret = MMFILE_FORMAT_FAIL;
+ goto exception;
+ }
+
+ pFormatCtx = avformat_alloc_context();
if (!pFormatCtx) {
- debug_warning(DEBUG, "failed to find av stream. maybe corrupted data.\n");
+ debug_warning(DEBUG, "failed to avformat_alloc_context\n");
ret = MMFILE_FORMAT_FAIL;
goto exception;
}
+ pFormatCtx->pb = pIOCtx;
+
+ ret = avformat_open_input(&pFormatCtx, "", grab_iformat, NULL);
+ if (ret < 0) {
+ debug_error(DEBUG, "error: cannot open %s %d\n", urifilename, ret);
+ goto exception;
+ }
+
ret = __mmfile_get_frame(pFormatCtx, timestamp, is_accurate, frame, size, width, height);
exception:
/* Close video file */
- if (pFormatCtx) avformat_close_input(&pFormatCtx);
+ if (pIOCtx) {
+ av_free(pIOCtx->buffer);
+ av_free(pIOCtx->opaque);
+ av_free(pIOCtx);
+ }
- ffurl_deregister_protocol(&MMFileMEMProtocol);
+ if (pFormatCtx)
+ avformat_close_input(&pFormatCtx);
return ret;
}
Name: libmm-fileinfo
Summary: Media Fileinfo
-Version: 0.6.64
+Version: 0.6.65
Release: 0
Group: System/Libraries
License: Apache-2.0
#define MMFILE_MEM_URI_LEN 6
#define MMFILE_MMAP_URI "mmap://"
#define MMFILE_MMAP_URI_LEN 7
+#define MMFILE_AVIO_BUFFER_LEN 32768
#define MMFILE_RDONLY O_RDONLY
#define MMFILE_WRONLY O_WRONLY