Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71b9fb4f authored by Hangyu Kuang's avatar Hangyu Kuang
Browse files

MediatranscodingService: Create MediaTranscodingService.

"adb shell dumpsys -l | grep media" shows media.transcoding service.

This CL only adds the skelton to start the service and hook up with the
libmediatranscoding librarie now. But it does not do anything yet. The
implementation will be added in the next few Cls.

Bug:145233472
Test: Build and run.

Change-Id: I09021b811e5bd935735b0b936c55639496799ae1
parent 06069a56
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
---
BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
BinPackArguments: true
BinPackParameters: true
CommentPragmas: NOLINT:.*
ContinuationIndentWidth: 8
DerivePointerAlignment: false
IndentWidth: 4
PointerAlignment: Left
TabWidth: 4

# Deviations from the above file:
# "Don't indent the section label"
AccessModifierOffset: -4
# "Each line of text in your code should be at most 100 columns long."
ColumnLimit: 100
# "Constructor initializer lists can be all on one line or with subsequent
# lines indented eight spaces.". clang-format does not support having the colon
# on the same line as the constructor function name, so this is the best
# approximation of that rule, which makes all entries in the list (except the
# first one) have an eight space indentation.
ConstructorInitializerIndentWidth: 6
# There is nothing in go/droidcppstyle about case labels, but there seems to be
# more code that does not indent the case labels in frameworks/base.
IndentCaseLabels: false
# There have been some bugs in which subsequent formatting operations introduce
# weird comment jumps.
ReflowComments: false
# Android does support C++11 now.
Standard: Cpp11
 No newline at end of file
+60 −0
Original line number Diff line number Diff line
// service library
cc_library_shared {
    name: "libmediatranscodingservice",

    srcs: ["MediaTranscodingService.cpp"],

    shared_libs: [
        "libbinder_ndk",
        "liblog",
    ],

    static_libs: [
        "mediatranscoding_aidl_interface-ndk_platform",
    ],

    cflags: [
        "-Werror",
        "-Wall",
    ],
}

cc_binary {
    name: "mediatranscoding",

    srcs: [
        "main_mediatranscodingservice.cpp",
    ],

    shared_libs: [
        // TODO(hkuang): Use libbinder_ndk
        "libbinder",
        "libutils",
        "liblog",
        "libbase",
        "libmediatranscodingservice",
    ],

    static_libs: [
        "mediatranscoding_aidl_interface-ndk_platform",
    ],

    target: {
        android: {
            product_variables: {
                malloc_not_svelte: {
                    // Scudo increases memory footprint, so only enable on
                    // non-svelte devices.
                    shared_libs: ["libc_scudo"],
                },
            },
        },
    },

    init_rc: ["mediatranscoding.rc"],

    cflags: [
        "-Werror",
        "-Wall",
    ],
}
+0 −0

Empty file added.

+89 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * 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.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "MediaTranscodingService"
#include "MediaTranscodingService.h"

#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <utils/Log.h>
#include <utils/Vector.h>

namespace android {

namespace media {

using android::media::MediaTranscodingService;

MediaTranscodingService::MediaTranscodingService() {
    ALOGV("MediaTranscodingService is created");
}

MediaTranscodingService::~MediaTranscodingService() {
    ALOGE("Should not be in ~MediaTranscodingService");
}

binder_status_t MediaTranscodingService::dump(int /* fd */, const char** /*args*/,
                                              uint32_t /*numArgs*/) {
    // TODO(hkuang): Add implementation.
    return OK;
}

//static
void MediaTranscodingService::instantiate() {
    std::shared_ptr<MediaTranscodingService> service =
            ::ndk::SharedRefBase::make<MediaTranscodingService>();
    binder_status_t status =
            AServiceManager_addService(service->asBinder().get(), getServiceName());
    if (status != STATUS_OK) {
        return;
    }
}

Status MediaTranscodingService::registerClient(
        const std::shared_ptr<ITranscodingServiceClient>& /*in_client*/,
        int32_t* /*_aidl_return*/) {
    // TODO(hkuang): Add implementation.
    return Status::ok();
}

Status MediaTranscodingService::unregisterClient(int32_t /*clientId*/, bool* /*_aidl_return*/) {
    // TODO(hkuang): Add implementation.
    return Status::ok();
}

Status MediaTranscodingService::submitRequest(int32_t /*clientId*/,
                                              const TranscodingRequest& /*request*/,
                                              TranscodingJob* /*job*/, int32_t* /*_aidl_return*/) {
    // TODO(hkuang): Add implementation.
    return Status::ok();
}

Status MediaTranscodingService::cancelJob(int32_t /*in_clientId*/, int32_t /*in_jobId*/,
                                          bool* /*_aidl_return*/) {
    // TODO(hkuang): Add implementation.
    return Status::ok();
}

Status MediaTranscodingService::getJobWithId(int32_t /*in_jobId*/, TranscodingJob* /*out_job*/,
                                             bool* /*_aidl_return*/) {
    // TODO(hkuang): Add implementation.
    return Status::ok();
}

}  // namespace media
}  // namespace android
+62 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * 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 ANDROID_MEDIA_TRANSCODING_SERVICE_H
#define ANDROID_MEDIA_TRANSCODING_SERVICE_H

#include <aidl/android/media/BnMediaTranscodingService.h>
#include <binder/IServiceManager.h>

namespace android {

namespace media {

using Status = ::ndk::ScopedAStatus;
using ::aidl::android::media::BnMediaTranscodingService;
using ::aidl::android::media::ITranscodingServiceClient;
using ::aidl::android::media::TranscodingJob;
using ::aidl::android::media::TranscodingRequest;

class MediaTranscodingService : public BnMediaTranscodingService {
public:
    MediaTranscodingService();
    virtual ~MediaTranscodingService();

    static void instantiate();

    static const char* getServiceName() { return "media.transcoding"; }

    Status registerClient(const std::shared_ptr<ITranscodingServiceClient>& in_client,
                          int32_t* _aidl_return) override;

    Status unregisterClient(int32_t clientId, bool* _aidl_return) override;

    Status submitRequest(int32_t in_clientId, const TranscodingRequest& in_request,
                         TranscodingJob* out_job, int32_t* _aidl_return) override;

    Status cancelJob(int32_t in_clientId, int32_t in_jobId, bool* _aidl_return) override;

    Status getJobWithId(int32_t in_jobId, TranscodingJob* out_job, bool* _aidl_return) override;

    virtual inline binder_status_t dump(int /*fd*/, const char** /*args*/, uint32_t /*numArgs*/);

private:
};

}  // namespace media
}  // namespace android

#endif  // ANDROID_MEDIA_TRANSCODING_SERVICE_H
Loading