refactor(codec): de-Qt oakcodec and wrap it in a pure C ABI; switch common handles to refcounted value structs
- oakcodec: de-Qt all 20 sources (QThread decode loop -> std::thread,
QObject/signals -> callbacks), pure C ABI in include/codec with
refcounted neutral handles (OakFrame/OakDecoder/OakEncoder),
framemanager moved in from render, frame_to_buffer/buffer_to_frame
moved in from oakcommon oiioutils, codec->task via submit callback
(M8 will register), all cross-module calls go through the other
side's C API, -fvisibility=hidden + OAKCODEC_API
- oakcommon: handles become refcounted value structs
{ctx, addref, release, abi_version} (FFmpeg-style), pass-by-value
signatures, free() as release wrapper; init_from_native/get_native
for copyable value objects; OakCommonXxx renamed to OakXxx
- oakcommon: add logging (log_debug/info/warning/critical with level
filtering and sink injection) + printf-style oakcommon_log C wrapper
- oakrender: add CancelAtom C API family; complete
oakrender_color_processor_convert_frame; fix get_processor() missing
definition and OCIO env var lookup
- tests: oakcommon 174, oaknode 96, oakrender 42, oakcodec 18, all
green in their standalone builds
This commit is contained in:
+59
-25
@@ -22,26 +22,56 @@
|
||||
#define OAK_EDITOR_XMLUTILS_H
|
||||
|
||||
#include "common/error.h"
|
||||
#include "common/handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct OakCommonXmlReader OakCommonXmlReader;
|
||||
typedef struct OakCommonXmlWriter OakCommonXmlWriter;
|
||||
/**
|
||||
* @brief Neutral by-value handle to a streaming XML reader.
|
||||
*
|
||||
* Ownership/count semantics follow the convention in common/handle.h:
|
||||
* init returns a handle whose object has reference count 1,
|
||||
* addref(ctx)/release(ctx) adjust it atomically, and release destroys
|
||||
* the object at zero. abi_version is always OAKCOMMON_ABI_VERSION.
|
||||
*/
|
||||
typedef struct OakXmlReader {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakXmlReader;
|
||||
|
||||
/**
|
||||
* @brief Neutral by-value handle to a streaming XML writer.
|
||||
*
|
||||
* Same ownership/count semantics as OakXmlReader.
|
||||
*/
|
||||
typedef struct OakXmlWriter {
|
||||
void *ctx; /**< Opaque pointer to the reference-counted object. */
|
||||
void (*addref)(void *ctx); /**< Atomically increments the count. */
|
||||
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
|
||||
uint32_t abi_version; /**< OAKCOMMON_ABI_VERSION. */
|
||||
} OakXmlWriter;
|
||||
|
||||
/**
|
||||
* @brief Create a streaming XML reader over a complete document.
|
||||
*
|
||||
* @param data NUL-terminated XML text. Must not be NULL.
|
||||
* @return A new reader, or NULL on failure (NULL data, out of memory).
|
||||
* @return Handle with reference count 1; ctx is NULL on failure
|
||||
* (NULL data, out of memory).
|
||||
*/
|
||||
OakCommonXmlReader *oakcommon_xml_reader_init(const char *data);
|
||||
OakXmlReader oakcommon_xml_reader_init(const char *data);
|
||||
|
||||
/**
|
||||
* @brief Destroy a reader. No-op on NULL.
|
||||
* @brief Release one reference to a reader.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when reader is NULL or reader->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_xml_reader_free(OakCommonXmlReader *reader);
|
||||
void oakcommon_xml_reader_free(OakXmlReader *reader);
|
||||
|
||||
/**
|
||||
* @brief Advance until the next start element, an end element, or the end
|
||||
@@ -51,7 +81,7 @@ void oakcommon_xml_reader_free(OakCommonXmlReader *reader);
|
||||
* @param found Out: 1 if positioned on a start element, 0 otherwise.
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_read_next_start_element(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_read_next_start_element(OakXmlReader reader,
|
||||
int *found);
|
||||
|
||||
/**
|
||||
@@ -60,7 +90,7 @@ int oakcommon_xml_reader_read_next_start_element(OakCommonXmlReader *reader,
|
||||
* @return Required buffer size in bytes (including NUL), or a negative
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_name(OakCommonXmlReader *reader, char *buf,
|
||||
int oakcommon_xml_reader_name(OakXmlReader reader, char *buf,
|
||||
int buf_size);
|
||||
|
||||
/**
|
||||
@@ -72,7 +102,7 @@ int oakcommon_xml_reader_name(OakCommonXmlReader *reader, char *buf,
|
||||
* @return Required buffer size in bytes (including NUL), or a negative
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_read_element_text(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_read_element_text(OakXmlReader reader,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -80,14 +110,14 @@ int oakcommon_xml_reader_read_element_text(OakCommonXmlReader *reader,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_skip_current_element(OakCommonXmlReader *reader);
|
||||
int oakcommon_xml_reader_skip_current_element(OakXmlReader reader);
|
||||
|
||||
/**
|
||||
* @brief Number of attributes on the current start element.
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_attribute_count(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_attribute_count(OakXmlReader reader,
|
||||
int *count);
|
||||
|
||||
/**
|
||||
@@ -96,7 +126,7 @@ int oakcommon_xml_reader_attribute_count(OakCommonXmlReader *reader,
|
||||
* @return Required buffer size in bytes (including NUL), OAKCOMMON_E_NOT_FOUND
|
||||
* if @p index is out of range, or another negative OAKCOMMON_E_* code.
|
||||
*/
|
||||
int oakcommon_xml_reader_attribute_name(OakCommonXmlReader *reader, int index,
|
||||
int oakcommon_xml_reader_attribute_name(OakXmlReader reader, int index,
|
||||
char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -105,7 +135,7 @@ int oakcommon_xml_reader_attribute_name(OakCommonXmlReader *reader, int index,
|
||||
* @return Required buffer size in bytes (including NUL), OAKCOMMON_E_NOT_FOUND
|
||||
* if @p index is out of range, or another negative OAKCOMMON_E_* code.
|
||||
*/
|
||||
int oakcommon_xml_reader_attribute_value(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_attribute_value(OakXmlReader reader,
|
||||
int index, char *buf, int buf_size);
|
||||
|
||||
/**
|
||||
@@ -113,32 +143,36 @@ int oakcommon_xml_reader_attribute_value(OakCommonXmlReader *reader,
|
||||
*
|
||||
* @return OAKCOMMON_OK or a negative OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_reader_has_error(OakCommonXmlReader *reader,
|
||||
int oakcommon_xml_reader_has_error(OakXmlReader reader,
|
||||
int *has_error);
|
||||
|
||||
/**
|
||||
* @brief Create a streaming XML writer.
|
||||
*
|
||||
* @return A new writer, or NULL on failure.
|
||||
* @return Handle with reference count 1; ctx is NULL on failure.
|
||||
*/
|
||||
OakCommonXmlWriter *oakcommon_xml_writer_init(void);
|
||||
OakXmlWriter oakcommon_xml_writer_init(void);
|
||||
|
||||
/**
|
||||
* @brief Destroy a writer. No-op on NULL.
|
||||
* @brief Release one reference to a writer.
|
||||
*
|
||||
* Convenience wrapper around handle.release(handle.ctx): decrements the
|
||||
* atomic reference count and destroys the object when it reaches zero.
|
||||
* No-op when writer is NULL or writer->ctx is NULL.
|
||||
*/
|
||||
void oakcommon_xml_writer_free(OakCommonXmlWriter *writer);
|
||||
void oakcommon_xml_writer_free(OakXmlWriter *writer);
|
||||
|
||||
int oakcommon_xml_writer_write_start_element(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_start_element(OakXmlWriter writer,
|
||||
const char *name);
|
||||
int oakcommon_xml_writer_write_attribute(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_attribute(OakXmlWriter writer,
|
||||
const char *name, const char *value);
|
||||
int oakcommon_xml_writer_write_characters(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_characters(OakXmlWriter writer,
|
||||
const char *text);
|
||||
int oakcommon_xml_writer_write_text_element(OakCommonXmlWriter *writer,
|
||||
int oakcommon_xml_writer_write_text_element(OakXmlWriter writer,
|
||||
const char *name,
|
||||
const char *text);
|
||||
int oakcommon_xml_writer_write_end_element(OakCommonXmlWriter *writer);
|
||||
int oakcommon_xml_writer_write_end_document(OakCommonXmlWriter *writer);
|
||||
int oakcommon_xml_writer_write_end_element(OakXmlWriter writer);
|
||||
int oakcommon_xml_writer_write_end_document(OakXmlWriter writer);
|
||||
|
||||
/**
|
||||
* @brief The document written so far.
|
||||
@@ -146,7 +180,7 @@ int oakcommon_xml_writer_write_end_document(OakCommonXmlWriter *writer);
|
||||
* @return Required buffer size in bytes (including NUL), or a negative
|
||||
* OAKCOMMON_E_* error code.
|
||||
*/
|
||||
int oakcommon_xml_writer_output(OakCommonXmlWriter *writer, char *buf,
|
||||
int oakcommon_xml_writer_output(OakXmlWriter writer, char *buf,
|
||||
int buf_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user