OMX_ERRORTYPE AudioSource::GetConfig(
        OMX_INDEXTYPE nParamIndex,
        OMX_PTR pStructure)
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    switch ((int)nParamIndex) {
        case OMX_IndexConfigAudioVolume:
            {
                OMX_AUDIO_CONFIG_VOLUMETYPE *pVolume;
                pVolume = (OMX_AUDIO_CONFIG_VOLUMETYPE*)pStructure;
                CHECK_STRUCT(pVolume, OMX_AUDIO_CONFIG_VOLUMETYPE, ret);
				fsl_osal_memcpy(pVolume, &Volume, sizeof(OMX_AUDIO_CONFIG_VOLUMETYPE));
            }
            break;
        case OMX_IndexConfigAudioMute:
             {
                OMX_AUDIO_CONFIG_MUTETYPE *pMute;
                pMute = (OMX_AUDIO_CONFIG_MUTETYPE*)pStructure;
                CHECK_STRUCT(pMute, OMX_AUDIO_CONFIG_MUTETYPE, ret);
				fsl_osal_memcpy(pMute, &Mute, sizeof(OMX_AUDIO_CONFIG_MUTETYPE));
            }
            break;
        case OMX_IndexConfigMaxAmplitude:
            {
				 *((OMX_S32*)pStructure) = getMaxAmplitude();
            }
            break;
        default:
            ret = OMX_ErrorUnsupportedIndex;
            break;
    }

    return ret;
}
Beispiel #2
0
bool DS345::isValidAmplitude(const double &new_amplitude, const QString &waveform, const QString &unit) const
{
    if (!isValidAmplitudeType(unit))
        return false;
    return (getMinAmplitude(waveform, unit) <= new_amplitude &&
            new_amplitude <= getMaxAmplitude(waveform, unit));
}
status_t BnMediaRecorder::onTransact(
                                     uint32_t code, const Parcel& data, Parcel* reply,
                                     uint32_t flags)
{
    switch (code) {
        case RELEASE: {
            ALOGV("RELEASE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(release());
            return NO_ERROR;
        } break;
        case INIT: {
            ALOGV("INIT");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(init());
            return NO_ERROR;
        } break;
        case CLOSE: {
            ALOGV("CLOSE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(close());
            return NO_ERROR;
        } break;
        case RESET: {
            ALOGV("RESET");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(reset());
            return NO_ERROR;
        } break;
        case STOP: {
            ALOGV("STOP");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(stop());
            return NO_ERROR;
        } break;
        case START: {
            ALOGV("START");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(start());
            return NO_ERROR;
        } break;
        case PREPARE: {
            ALOGV("PREPARE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(prepare());
            return NO_ERROR;
        } break;
        case GET_MAX_AMPLITUDE: {
            ALOGV("GET_MAX_AMPLITUDE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int max = 0;
            status_t ret = getMaxAmplitude(&max);
            reply->writeInt32(max);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;
        case SET_VIDEO_SOURCE: {
            ALOGV("SET_VIDEO_SOURCE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int vs = data.readInt32();
            reply->writeInt32(setVideoSource(vs));
            return NO_ERROR;
        } break;
        case SET_AUDIO_SOURCE: {
            ALOGV("SET_AUDIO_SOURCE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int as = data.readInt32();
            reply->writeInt32(setAudioSource(as));
            return NO_ERROR;
        } break;
        case SET_OUTPUT_FORMAT: {
            ALOGV("SET_OUTPUT_FORMAT");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int of = data.readInt32();
            reply->writeInt32(setOutputFormat(of));
            return NO_ERROR;
        } break;
        case SET_VIDEO_ENCODER: {
            ALOGV("SET_VIDEO_ENCODER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int ve = data.readInt32();
            reply->writeInt32(setVideoEncoder(ve));
            return NO_ERROR;
        } break;
        case SET_AUDIO_ENCODER: {
            ALOGV("SET_AUDIO_ENCODER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int ae = data.readInt32();
            reply->writeInt32(setAudioEncoder(ae));
            return NO_ERROR;

        } break;
        case SET_OUTPUT_FILE_FD: {
            ALOGV("SET_OUTPUT_FILE_FD");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int fd = dup(data.readFileDescriptor());
            int64_t offset = data.readInt64();
            int64_t length = data.readInt64();
            reply->writeInt32(setOutputFile(fd, offset, length));
            ::close(fd);
            return NO_ERROR;
        } break;
        case SET_VIDEO_SIZE: {
            ALOGV("SET_VIDEO_SIZE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int width = data.readInt32();
            int height = data.readInt32();
            reply->writeInt32(setVideoSize(width, height));
            return NO_ERROR;
        } break;
        case SET_VIDEO_FRAMERATE: {
            ALOGV("SET_VIDEO_FRAMERATE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            int frames_per_second = data.readInt32();
            reply->writeInt32(setVideoFrameRate(frames_per_second));
            return NO_ERROR;
        } break;
        case SET_PARAMETERS: {
            ALOGV("SET_PARAMETER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(setParameters(data.readString8()));
            return NO_ERROR;
        } break;
        case SET_LISTENER: {
            ALOGV("SET_LISTENER");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<IMediaRecorderClient> listener =
                interface_cast<IMediaRecorderClient>(data.readStrongBinder());
            reply->writeInt32(setListener(listener));
            return NO_ERROR;
        } break;
        case SET_CLIENT_NAME: {
            ALOGV("SET_CLIENT_NAME");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            reply->writeInt32(setClientName(data.readString16()));
            return NO_ERROR;
        }
        case SET_PREVIEW_SURFACE: {
            ALOGV("SET_PREVIEW_SURFACE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(
                    data.readStrongBinder());
            reply->writeInt32(setPreviewSurface(surface));
            return NO_ERROR;
        } break;
        case SET_CAMERA: {
            ALOGV("SET_CAMERA");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<ICamera> camera = interface_cast<ICamera>(data.readStrongBinder());
            sp<ICameraRecordingProxy> proxy =
                interface_cast<ICameraRecordingProxy>(data.readStrongBinder());
            reply->writeInt32(setCamera(camera, proxy));
            return NO_ERROR;
        } break;
        case SET_INPUT_SURFACE: {
            ALOGV("SET_INPUT_SURFACE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            sp<IGraphicBufferConsumer> surface = interface_cast<IGraphicBufferConsumer>(
                    data.readStrongBinder());
            reply->writeInt32(setInputSurface(surface));
            return NO_ERROR;
        } break;
        case QUERY_SURFACE_MEDIASOURCE: {
            ALOGV("QUERY_SURFACE_MEDIASOURCE");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            // call the mediaserver side to create
            // a surfacemediasource
            sp<IGraphicBufferProducer> surfaceMediaSource = querySurfaceMediaSource();
            // The mediaserver might have failed to create a source
            int returnedNull= (surfaceMediaSource == NULL) ? 1 : 0 ;
            reply->writeInt32(returnedNull);
            if (!returnedNull) {
                reply->writeStrongBinder(IInterface::asBinder(surfaceMediaSource));
            }
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnMediaRecorder::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
    case RELEASE: {
        LOGV("RELEASE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(release());
        return NO_ERROR;
    }
    break;
    case INIT: {
        LOGV("INIT");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(init());
        return NO_ERROR;
    }
    break;
    case CLOSE: {
        LOGV("CLOSE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(close());
        return NO_ERROR;
    }
    break;
    case RESET: {
        LOGV("RESET");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(reset());
        return NO_ERROR;
    }
    break;
    case STOP: {
        LOGV("STOP");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(stop());
        return NO_ERROR;
    }
    break;
    case START: {
        LOGV("START");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(start());
        return NO_ERROR;
    }
    break;
    case PREPARE: {
        LOGV("PREPARE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(prepare());
        return NO_ERROR;
    }
    break;
    case GET_MAX_AMPLITUDE: {
        LOGV("GET_MAX_AMPLITUDE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int max = 0;
        status_t ret = getMaxAmplitude(&max);
        reply->writeInt32(max);
        reply->writeInt32(ret);
        return NO_ERROR;
    }
    break;
    case SET_VIDEO_SOURCE: {
        LOGV("SET_VIDEO_SOURCE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int vs = data.readInt32();
        reply->writeInt32(setVideoSource(vs));
        return NO_ERROR;
    }
    break;
    case SET_AUDIO_SOURCE: {
        LOGV("SET_AUDIO_SOURCE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int as = data.readInt32();
        reply->writeInt32(setAudioSource(as));
        return NO_ERROR;
    }
    break;
    case SET_OUTPUT_FORMAT: {
        LOGV("SET_OUTPUT_FORMAT");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int of = data.readInt32();
        reply->writeInt32(setOutputFormat(of));
        return NO_ERROR;
    }
    break;
    case SET_VIDEO_ENCODER: {
        LOGV("SET_VIDEO_ENCODER");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int ve = data.readInt32();
        reply->writeInt32(setVideoEncoder(ve));
        return NO_ERROR;
    }
    break;
    case SET_AUDIO_ENCODER: {
        LOGV("SET_AUDIO_ENCODER");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int ae = data.readInt32();
        reply->writeInt32(setAudioEncoder(ae));
        return NO_ERROR;

    }
    break;
    case SET_OUTPUT_FILE_PATH: {
        LOGV("SET_OUTPUT_FILE_PATH");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        const char* path = data.readCString();
        reply->writeInt32(setOutputFile(path));
        return NO_ERROR;
    }
    break;
    case SET_OUTPUT_FILE_FD: {
        LOGV("SET_OUTPUT_FILE_FD");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int fd = dup(data.readFileDescriptor());
        int64_t offset = data.readInt64();
        int64_t length = data.readInt64();
        reply->writeInt32(setOutputFile(fd, offset, length));
        return NO_ERROR;
    }
    break;
    case SET_VIDEO_SIZE: {
        LOGV("SET_VIDEO_SIZE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int width = data.readInt32();
        int height = data.readInt32();
        reply->writeInt32(setVideoSize(width, height));
        return NO_ERROR;
    }
    break;
    case SET_VIDEO_FRAMERATE: {
        LOGV("SET_VIDEO_FRAMERATE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        int frames_per_second = data.readInt32();
        reply->writeInt32(setVideoFrameRate(frames_per_second));
        return NO_ERROR;
    }
    break;
    case SET_PARAMETERS: {
        LOGV("SET_PARAMETER");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        reply->writeInt32(setParameters(data.readString8()));
        return NO_ERROR;
    }
    break;
    case SET_LISTENER: {
        LOGV("SET_LISTENER");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        sp<IMediaPlayerClient> listener =
            interface_cast<IMediaPlayerClient>(data.readStrongBinder());
        reply->writeInt32(setListener(listener));
        return NO_ERROR;
    }
    break;
    case SET_PREVIEW_SURFACE: {
        LOGV("SET_PREVIEW_SURFACE");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
        reply->writeInt32(setPreviewSurface(surface));
        return NO_ERROR;
    }
    break;
    case SET_CAMERA: {
        LOGV("SET_CAMERA");
        CHECK_INTERFACE(IMediaRecorder, data, reply);
        sp<ICamera> camera = interface_cast<ICamera>(data.readStrongBinder());
        reply->writeInt32(setCamera(camera));
        return NO_ERROR;
    }
    break;
    default:
        return BBinder::onTransact(code, data, reply, flags);
    }
}