-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
2,206 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project(mfcdm_library) | ||
|
||
add_library(mfcdm_library STATIC | ||
mfcdm/MediaFoundationCdm.h | ||
mfcdm/MediaFoundationCdm.cpp | ||
mfcdm/MediaFoundationCdmFactory.cpp | ||
mfcdm/MediaFoundationCdmSession.cpp | ||
mfcdm/MediaFoundationSession.cpp | ||
mfcdm/Log.cpp | ||
) | ||
|
||
target_include_directories(mfcdm_library PUBLIC ${PROJECT_SOURCE_DIR}) | ||
|
||
target_link_libraries(mfcdm_library PRIVATE cdm_library propsys mf mfplat mfplay mfreadwrite mfuuid wmcodecdspuuid) | ||
|
||
set_target_properties(mfcdm_library PROPERTIES POSITION_INDEPENDENT_CODE True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "Log.h" | ||
|
||
#include <cstdarg> | ||
#include <cstdio> | ||
|
||
typedef struct | ||
{ | ||
const char* name; | ||
int cur_level; | ||
void (*msg_callback)(int level, char* msg); | ||
} debug_ctx_t; | ||
|
||
static debug_ctx_t debug_ctx = {"MF", MFCDM::MFLOG_NONE, NULL}; | ||
|
||
|
||
static inline void __dbg(debug_ctx_t* ctx, int level, const char* fmt, va_list ap) | ||
{ | ||
if (ctx != NULL && level <= ctx->cur_level) | ||
{ | ||
char msg[4096]; | ||
int len = snprintf(msg, sizeof(msg), "[%s] ", ctx->name); | ||
vsnprintf(msg + len, sizeof(msg) - len, fmt, ap); | ||
if (ctx->msg_callback) | ||
{ | ||
ctx->msg_callback(level, msg); | ||
} | ||
} | ||
} | ||
|
||
void MFCDM::LogAll() | ||
{ | ||
debug_ctx.cur_level = MFLOG_ALL; | ||
} | ||
|
||
void MFCDM::Log(LogLevel level, const char* fmt, ...) | ||
{ | ||
va_list ap; | ||
|
||
va_start(ap, fmt); | ||
__dbg(&debug_ctx, level, fmt, ap); | ||
va_end(ap); | ||
} | ||
|
||
void MFCDM::SetMFMsgCallback(void (*msgcb)(int level, char*)) | ||
{ | ||
debug_ctx.msg_callback = msgcb; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace MFCDM | ||
{ | ||
enum LogLevel | ||
{ | ||
MFLOG_NONE = -1, | ||
MFLOG_ERROR, | ||
MFLOG_WARN, | ||
MFLOG_INFO, | ||
MFLOG_DEBUG, | ||
MFLOG_ALL = 100 | ||
}; | ||
|
||
void LogAll(); | ||
void Log(LogLevel level, const char* fmt, ...); | ||
void SetMFMsgCallback(void (*msgcb)(int level, char*)); | ||
|
||
} // namespace MFCDM |
Oops, something went wrong.