Skip to content

Commit

Permalink
Code style check
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowei-guan committed Dec 28, 2023
1 parent 9530d80 commit a38394e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
#define FLUTTER_PLUGIN_DRM_LICENSE_REQUEST_H_

#include <functional>
#include <memory>
#include <string>
#include <vector>

using OnLicenseRequestDone = std::function<void(
const std::string& session_id, std::vector<uint8_t>& response_data)>;
const std::string& session_id, const std::vector<uint8_t>& response_data)>;
class DrmLicenseRequest
: public std::enable_shared_from_this<DrmLicenseRequest> {
public:
DrmLicenseRequest(OnLicenseRequestDone on_license_request_done_callback)
explicit DrmLicenseRequest(
OnLicenseRequestDone on_license_request_done_callback)
: on_license_request_done_callback_(on_license_request_done_callback) {}
virtual ~DrmLicenseRequest(){};
virtual ~DrmLicenseRequest() {}
virtual void RequestLicense(void* session_id, int message_type, void* message,
int message_length) = 0;
virtual void OnLicenseResponse(const std::string& session_id,
std::vector<uint8_t>& response_data) = 0;
const std::vector<uint8_t>& response_data) = 0;

protected:
std::shared_ptr<DrmLicenseRequest> getShared() { return shared_from_this(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <flutter/method_result_functions.h>
#include <flutter/standard_method_codec.h>

#include <utility>

#include "log.h"

DrmLicenseRequestChannel::DrmLicenseRequestChannel(
Expand Down Expand Up @@ -42,14 +44,14 @@ void DrmLicenseRequestChannel::ExecuteRequest() {
}

void DrmLicenseRequestChannel::PushLicenseRequestData(
DataForLicenseProcess &data) {
const DataForLicenseProcess &data) {
std::lock_guard<std::mutex> lock(queue_mutex_);
license_request_queue_.push(data);
ecore_pipe_write(license_request_pipe_, nullptr, 0);
}

void DrmLicenseRequestChannel::RequestLicense(std::string &session_id,
std::string &message) {
void DrmLicenseRequestChannel::RequestLicense(const std::string &session_id,
const std::string &message) {
LOG_INFO("[DrmLicenseRequestChannel] Start request license.");

if (request_license_channel_ == nullptr) {
Expand Down Expand Up @@ -86,7 +88,7 @@ void DrmLicenseRequestChannel::RequestLicense(std::string &session_id,
}

void DrmLicenseRequestChannel::OnLicenseResponse(
const std::string &session_id, std::vector<uint8_t> &response_data) {
const std::string &session_id, const std::vector<uint8_t> &response_data) {
if (on_license_request_done_callback_) {
on_license_request_done_callback_(session_id, response_data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <memory>
#include <mutex>
#include <queue>
#include <string>
#include <vector>

#include "drm_license_request.h"

Expand All @@ -31,12 +33,13 @@ class DrmLicenseRequestChannel : public DrmLicenseRequest {
int message_length) override;
~DrmLicenseRequestChannel();
void OnLicenseResponse(const std::string &session_id,
std::vector<uint8_t> &response_data) override;
const std::vector<uint8_t> &response_data) override;

private:
void ExecuteRequest();
void PushLicenseRequestData(DataForLicenseProcess &data);
void RequestLicense(std::string &session_id, std::string &message);
void PushLicenseRequestData(const DataForLicenseProcess &data);
void RequestLicense(const std::string &session_id,
const std::string &message);
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>>
request_license_channel_;
std::mutex queue_mutex_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void DrmLicenseRequestNative::ExecuteResponse() {
}

void DrmLicenseRequestNative::OnLicenseResponse(
const std::string& session_id, std::vector<uint8_t>& response_data) {
const std::string& session_id, const std::vector<uint8_t>& response_data) {
std::lock_guard<std::mutex> lock(queue_mutex_);
license_response_queue_.push(std::make_pair(session_id, response_data));
ecore_pipe_write(license_response_pipe_, nullptr, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <memory>
#include <mutex>
#include <queue>
#include <string>
#include <utility>
#include <vector>

#include "drm_license_request.h"

Expand All @@ -24,7 +26,7 @@ class DrmLicenseRequestNative : public DrmLicenseRequest {

protected:
void OnLicenseResponse(const std::string& session_id,
std::vector<uint8_t>& response_data) override;
const std::vector<uint8_t>& response_data) override;

private:
void StopMessageQueue();
Expand Down
8 changes: 4 additions & 4 deletions packages/video_player_videohole/tizen/src/drm/drm_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool DrmManager::SetChallenge(const std::string &media_url,
flutter::BinaryMessenger *binary_messenger) {
drm_license_request_ = std::make_shared<DrmLicenseRequestChannel>(
binary_messenger, [this](const std::string &session_id,
std::vector<uint8_t> &response_data) {
const std::vector<uint8_t> &response_data) {
InstallKey(session_id, response_data);
});
return DM_ERROR_NONE == SetChallenge(media_url);
Expand All @@ -98,7 +98,7 @@ bool DrmManager::SetChallenge(const std::string &media_url,
drm_license_request_ = std::make_shared<DrmLicenseRequestNative>(
drm_type_, license_server_url,
[this](const std::string &session_id,
std::vector<uint8_t> &response_data) {
const std::vector<uint8_t> &response_data) {
InstallKey(session_id, response_data);
});
return DM_ERROR_NONE == SetChallenge(media_url);
Expand Down Expand Up @@ -243,13 +243,13 @@ void DrmManager::OnDrmManagerError(long error_code, char *error_message,
}

void DrmManager::InstallKey(const std::string &session_id,
std::vector<uint8_t> &response) {
const std::vector<uint8_t> &response) {
LOG_INFO("[DrmManager] Start install license.");

SetDataParam_t license_param = {};
license_param.param1 =
reinterpret_cast<void *>(const_cast<char *>(session_id.c_str()));
license_param.param2 = response.data();
license_param.param2 = const_cast<uint8_t *>(response.data());
license_param.param3 = reinterpret_cast<void *>(response.size());
int ret = DMGRSetData(drm_session_, "install_eme_key", &license_param);
if (ret != DM_ERROR_NONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DrmManager {

private:
void InstallKey(const std::string &session_id,
std::vector<uint8_t> &response);
const std::vector<uint8_t> &response);
int SetChallenge(const std::string &media_url);

static int OnChallengeData(void *session_id, int message_type, void *message,
Expand Down
4 changes: 2 additions & 2 deletions packages/video_player_videohole/tizen/src/video_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class VideoPlayer {
virtual void SetDisplayRoi(int32_t x, int32_t y, int32_t width,
int32_t height) = 0;
virtual bool Play() = 0;
virtual bool Deactivate() { return false; };
virtual bool Activate() { return false; };
virtual bool Deactivate() { return false; }
virtual bool Activate() { return false; }
virtual bool Pause() = 0;
virtual bool SetLooping(bool is_looping) = 0;
virtual bool SetVolume(double volume) = 0;
Expand Down

0 comments on commit a38394e

Please sign in to comment.