Skip to content

Commit

Permalink
OP5 : Add for community
Browse files Browse the repository at this point in the history
Change-Id: I008fbf24134b327b9665ba17ef1466a288cd9f58
  • Loading branch information
likelong authored and dekefake committed Aug 19, 2017
1 parent 980d5c4 commit e238929
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion camera/cameraserver/cameraserver.rc 100644 → 100755
@@ -1,6 +1,6 @@
service cameraserver /system/bin/cameraserver
class main
user cameraserver
group audio camera input drmrpc
group audio camera input drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct system sdcard_rw
ioprio rt 4
writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks
4 changes: 4 additions & 0 deletions include/media/stagefright/MediaCodecSource.h
Expand Up @@ -145,6 +145,10 @@ struct MediaCodecSource : public MediaSource,

int32_t mGeneration;

int64_t mPrevBufferTimestampUs;
bool mIsHFR;
int32_t mBatchSize;

DISALLOW_EVIL_CONSTRUCTORS(MediaCodecSource);
};

Expand Down
3 changes: 3 additions & 0 deletions media/libavextensions/stagefright/AVExtensions.h
Expand Up @@ -35,6 +35,7 @@
#include <media/IOMX.h>
#include <camera/android/hardware/ICamera.h>
#include <media/mediarecorder.h>
#include <media/stagefright/MediaCodecSource.h>
#include "ESQueue.h"

namespace android {
Expand Down Expand Up @@ -152,6 +153,8 @@ struct AVUtils {

virtual bool isAudioMuxFormatSupported(const char *mime);
virtual void cacheCaptureBuffers(sp<hardware::ICamera> camera, video_encoder encoder);
virtual void getHFRParams(bool*, int32_t*, sp<AMessage>);
virtual int64_t overwriteTimeOffset(bool, int64_t, int64_t *, int64_t, int32_t);
virtual const char *getCustomCodecsLocation();
virtual const char *getCustomCodecsPerformanceLocation();

Expand Down
11 changes: 10 additions & 1 deletion media/libavextensions/stagefright/AVUtils.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 - 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2013 - 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -135,6 +135,15 @@ void AVUtils::cacheCaptureBuffers(sp<hardware::ICamera>, video_encoder) {
return;
}

void AVUtils::getHFRParams(bool*, int32_t*, sp<AMessage>) {
return;
}

int64_t AVUtils::overwriteTimeOffset(bool, int64_t inputBufferTimeOffsetUs, int64_t*,
int64_t, int32_t) {
return inputBufferTimeOffsetUs;
}

const char *AVUtils::getCustomCodecsLocation() {
return "/etc/media_codecs.xml";
}
Expand Down
1 change: 1 addition & 0 deletions media/libmediaplayerservice/StagefrightRecorder.cpp
Expand Up @@ -1609,6 +1609,7 @@ status_t StagefrightRecorder::setupVideoEncoder(
preferBFrames = false;
tsLayers = 2; // use at least two layers as resulting video will likely be sped up
} else if (mCaptureFps > maxPlaybackFps) { // slow-mo
format->setInt32("high-frame-rate", 1);
maxPlaybackFps = mCaptureFps; // assume video will be played back at full capture speed
preferBFrames = false;
}
Expand Down
10 changes: 7 additions & 3 deletions media/libstagefright/MediaCodecSource.cpp
Expand Up @@ -329,7 +329,7 @@ sp<MediaCodecSource> MediaCodecSource::Create(
uint32_t flags) {
sp<MediaCodecSource> mediaSource =
new MediaCodecSource(looper, format, source, consumer, flags);

AVUtils::get()->getHFRParams(&mediaSource->mIsHFR, &mediaSource->mBatchSize, format);
if (mediaSource->init() == OK) {
return mediaSource;
}
Expand Down Expand Up @@ -422,7 +422,10 @@ MediaCodecSource::MediaCodecSource(
mFirstSampleSystemTimeUs(-1ll),
mPausePending(false),
mFirstSampleTimeUs(-1ll),
mGeneration(0) {
mGeneration(0),
mPrevBufferTimestampUs(0),
mIsHFR(false),
mBatchSize(0) {
CHECK(mLooper != NULL);

AString mime;
Expand Down Expand Up @@ -685,7 +688,8 @@ status_t MediaCodecSource::feedEncoderInputBuffers() {
return OK;
}
}

mInputBufferTimeOffsetUs = AVUtils::get()->overwriteTimeOffset(mIsHFR,
mInputBufferTimeOffsetUs, &mPrevBufferTimestampUs, timeUs, mBatchSize);
timeUs += mInputBufferTimeOffsetUs;

// push decoding time for video, or drift time for audio
Expand Down
7 changes: 4 additions & 3 deletions services/camera/libcameraservice/CameraService.cpp 100644 → 100755
Expand Up @@ -76,6 +76,7 @@ using namespace hardware;
volatile int32_t gLogLevel = 0;
char gAppPackageName[50] = {'0'};

char gClientPackageName[50] = {'0'};
#define LOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define LOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);

Expand Down Expand Up @@ -1270,6 +1271,7 @@ Status CameraService::connect(
String8 id = String8::format("%d", cameraId);
strncpy(gAppPackageName, String8(clientPackageName).string(), sizeof(gAppPackageName));
sp<Client> client = nullptr;
strncpy(gClientPackageName, String8(clientPackageName).string(), sizeof(gClientPackageName));
ret = connectHelper<ICameraClient,Client>(cameraClient, id,
CAMERA_HAL_API_VERSION_UNSPECIFIED, clientPackageName, clientUid, clientPid, API_1,
/*legacyMode*/ false, /*shimUpdateOnly*/ false,
Expand Down Expand Up @@ -1315,7 +1317,7 @@ Status CameraService::connectLegacy(

Status ret = Status::ok();
sp<Client> client = nullptr;
strncpy(gAppPackageName, String8(clientPackageName).string(), sizeof(gAppPackageName));
strncpy(gClientPackageName, String8(clientPackageName).string(), sizeof(gClientPackageName));
ret = connectHelper<ICameraClient,Client>(cameraClient, id, halVersion,
clientPackageName, clientUid, USE_CALLING_PID, API_1,
/*legacyMode*/ true, /*shimUpdateOnly*/ false,
Expand Down Expand Up @@ -1343,8 +1345,7 @@ Status CameraService::connectDevice(
Status ret = Status::ok();
String8 id = String8::format("%d", cameraId);
sp<CameraDeviceClient> client = nullptr;

strncpy(gAppPackageName, String8(clientPackageName).string(), sizeof(gAppPackageName));
strncpy(gClientPackageName, String8(clientPackageName).string(), sizeof(gClientPackageName));
ret = connectHelper<hardware::camera2::ICameraDeviceCallbacks,CameraDeviceClient>(cameraCb, id,
CAMERA_HAL_API_VERSION_UNSPECIFIED, clientPackageName,
clientUid, USE_CALLING_PID, API_2,
Expand Down
1 change: 1 addition & 0 deletions services/camera/libcameraservice/CameraService.h 100644 → 100755
Expand Up @@ -48,6 +48,7 @@

namespace android {

extern char gClientPackageName[50];
extern volatile int32_t gLogLevel;
extern char gAppPackageName[50];

Expand Down

0 comments on commit e238929

Please sign in to comment.