MediaRecorder启动错误代码 [英] MediaRecorder start error codes

查看:213
本文介绍了MediaRecorder启动错误代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想录制无声音的原始h.264视频,并可能加快硬件的速度(稍后再进行流式传输).因此,我决定使用 MediaRecorder (和套接字 hack 进行流式传输).

I want to record raw h.264 video without sound and possibly HW accelerated (and stream it later). So I decided to use MediaRecorder (and the socket hack for streaming).

我有以下代码:

final MediaRecorder recorder = new MediaRecorder();
final Camera camera = Camera.open();
camera.unlock();
recorder.setCamera(camera);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
final CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
recorder.setVideoFrameRate(profile.videoFrameRate);
recorder.setVideoEncodingBitRate(profile.videoBitRate);
recorder.prepare();
recorder.start();

And!在logcat中:

And bam! This in logcat:

E/MediaRecorder﹕ start failed: -38

我开始谷歌搜索,发现了很多问题和答案,但没有发现关于我的错误代码 -38 的消息.

I started googling, and found plenty of questions and answers, but none about my error code -38.

所以我尝试查看Android 源代码,并注意到它是 native 方法,我不知道在哪里寻找.

So I tried to look at Android source code, and noticed it's native method, and I don't know where to look for that.

所以我的大问题是:这些错误代码是否存在一些列表,所以我可以找到 -38 意味着什么错误?

So my big question is: Is there some list of those error codes, so I could find what error -38 means?`

也知道我的目标是API 10(姜饼)并使用最新的SDK 21构建.

Also know tjat I'm targeting API 10 (Gingerbread) and building with latest SDK 21.

推荐答案

好的,我想我有一个答案.失败的启动功能在名为 mediarecorder.cpp 的文件中定义.在这里找到:

Alright, I think I have an answer for you. The start function that is failing is defined in a file called mediarecorder.cpp. Found here:

frameworks/av/media/libmedia/mediarecorder.cpp

此启动函数返回类型为 status_t 的变量,并与您看到的错误相对应.

This start function returns a variable of type status_t, and corresponds to the error that you're seeing thrown.

现在,在名为 Errors.h 的文件中定义了 status_t 类型:

Now, the type status_t is defined in a file called Errors.h which can be found here:

system/core/include/utils/Errors.h

这定义了对应于 status_t 的枚举,如下所示:

This defines an enumeration that corresponds to status_t as seen here:

enum {
    OK                = 0,    // Everything's swell.
    NO_ERROR          = 0,    // No errors.

    UNKNOWN_ERROR       = 0x80000000,

    NO_MEMORY           = -ENOMEM,
    INVALID_OPERATION   = -ENOSYS,
    BAD_VALUE           = -EINVAL,
    BAD_TYPE            = 0x80000001,
    NAME_NOT_FOUND      = -ENOENT,
    PERMISSION_DENIED   = -EPERM,
    NO_INIT             = -ENODEV,
    ALREADY_EXISTS      = -EEXIST,
    DEAD_OBJECT         = -EPIPE,
    FAILED_TRANSACTION  = 0x80000002,
    JPARKS_BROKE_IT     = -EPIPE,
#if !defined(HAVE_MS_C_RUNTIME)
    BAD_INDEX           = -EOVERFLOW,
    NOT_ENOUGH_DATA     = -ENODATA,
    WOULD_BLOCK         = -EWOULDBLOCK, 
    TIMED_OUT           = -ETIMEDOUT,
    UNKNOWN_TRANSACTION = -EBADMSG,
#else    
    BAD_INDEX           = -E2BIG,
    NOT_ENOUGH_DATA     = 0x80000003,
    WOULD_BLOCK         = 0x80000004,
    TIMED_OUT           = 0x80000005,
    UNKNOWN_TRANSACTION = 0x80000006,
#endif    
    FDS_NOT_ALLOWED     = 0x80000007,
};

如您所见,此处的某些值取自 errno.h ,因此我们只需要查看哪个值等于38.

As you can see, some of the values here are taken from errno.h, so we just need to see which one equates to a value of 38.

根据此来源,38对应于 ENOSYS.因此,如果我们回顾一下status_t枚举,我们可以看到在android中, ENOSYS 对应于无效操作.并不是很有帮助,但是我希望这至少可以为您指明正确的方向.

According to this source, 38 corresponds to ENOSYS. So, if we look back at the status_t enumeration, we can see that in android, ENOSYS corresponds to an invalid operation. Not terribly helpful, but I hope this at least points you in the right direction.

这篇关于MediaRecorder启动错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆