ref: 2da7ce40e73c98a5ab9040e41ab377e2a82e1811
parent: 7b669d31ad6b76c2a7e7f849afa2584c45e2ce69
author: Jean-Marc Valin <[email protected]>
date: Wed May 10 12:52:30 EDT 2017
Prefix OggOpusEnc functions with ope_encoder_
--- a/examples/opusenc_example.c
+++ b/examples/opusenc_example.c
@@ -20,7 +20,7 @@
comments = ope_comments_create();
ope_comments_add(comments, "ARTIST", "Someone");
ope_comments_add(comments, "TITLE", "Some track");
- enc = ope_create_file(argv[2], comments, 48000, 2, 0, &error);
+ enc = ope_encoder_create_file(argv[2], comments, 48000, 2, 0, &error);
if (!enc) {
fprintf(stderr, "cannout open output file: %s\n", argv[2]);
fclose(fin);
@@ -30,11 +30,11 @@
short buf[2*READ_SIZE];
int ret = fread(buf, 2*sizeof(short), READ_SIZE, fin);
if (ret > 0) {
- ope_write(enc, buf, ret);
+ ope_encoder_write(enc, buf, ret);
} else break;
}
- ope_drain(enc);
- ope_destroy(enc);
+ ope_encoder_drain(enc);
+ ope_encoder_destroy(enc);
ope_comments_destroy(comments);
fclose(fin);
return 0;
--- a/include/opusenc.h
+++ b/include/opusenc.h
@@ -122,41 +122,41 @@
/** Create a new OggOpus file. */
-OPE_EXPORT OggOpusEnc *ope_create_file(const char *path, const OggOpusComments *comments, int rate, int channels, int family, int *error);
+OPE_EXPORT OggOpusEnc *ope_encoder_create_file(const char *path, const OggOpusComments *comments, int rate, int channels, int family, int *error);
/** Create a new OggOpus file (callback-based). */
-OPE_EXPORT OggOpusEnc *ope_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
+OPE_EXPORT OggOpusEnc *ope_encoder_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
const OggOpusComments *comments, int rate, int channels, int family, int *error);
/** Create a new OggOpus stream, pulling one page at a time. */
-OPE_EXPORT OggOpusEnc *ope_create_pull(const OggOpusComments *comments, int rate, int channels, int family, int *error);
+OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(const OggOpusComments *comments, int rate, int channels, int family, int *error);
/** Add/encode any number of float samples to the file. */
-OPE_EXPORT int ope_write_float(OggOpusEnc *enc, const float *pcm, int samples_per_channel);
+OPE_EXPORT int ope_encoder_write_float(OggOpusEnc *enc, const float *pcm, int samples_per_channel);
/** Add/encode any number of int16 samples to the file. */
-OPE_EXPORT int ope_write(OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel);
+OPE_EXPORT int ope_encoder_write(OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel);
/** Get the next page from the stream. Returns 1 if there is a page available, 0 if not. */
-OPE_EXPORT int ope_get_page(OggOpusEnc *enc, unsigned char **page, int *len, int flush);
+OPE_EXPORT int ope_encoder_get_page(OggOpusEnc *enc, unsigned char **page, int *len, int flush);
/** Finalizes the stream, but does not deallocate the object. */
-OPE_EXPORT int ope_drain(OggOpusEnc *enc);
+OPE_EXPORT int ope_encoder_drain(OggOpusEnc *enc);
/** Deallocates the obect. Make sure to ope_drain() first. */
-OPE_EXPORT void ope_destroy(OggOpusEnc *enc);
+OPE_EXPORT void ope_encoder_destroy(OggOpusEnc *enc);
/** Ends the stream and create a new stream within the same file. */
-OPE_EXPORT int ope_chain_current(OggOpusEnc *enc, const OggOpusComments *comments);
+OPE_EXPORT int ope_encoder_chain_current(OggOpusEnc *enc, const OggOpusComments *comments);
/** Ends the stream and create a new file. */
-OPE_EXPORT int ope_continue_new_file(OggOpusEnc *enc, const char *path, const OggOpusComments *comments);
+OPE_EXPORT int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, const OggOpusComments *comments);
/** Ends the stream and create a new file (callback-based). */
-OPE_EXPORT int ope_continue_new_callbacks(OggOpusEnc *enc, void *user_data, const OggOpusComments *comments);
+OPE_EXPORT int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, const OggOpusComments *comments);
/** Write out the header now rather than wait for audio to begin. */
-OPE_EXPORT int ope_flush_header(OggOpusEnc *enc);
+OPE_EXPORT int ope_encoder_flush_header(OggOpusEnc *enc);
/** Goes straight to the libopus ctl() functions. */
OPE_EXPORT int ope_encoder_ctl(OggOpusEnc *enc, int request, ...);
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -250,11 +250,11 @@
};
/* Create a new OggOpus file. */
-OggOpusEnc *ope_create_file(const char *path, const OggOpusComments *comments, int rate, int channels, int family, int *error) {
+OggOpusEnc *ope_encoder_create_file(const char *path, const OggOpusComments *comments, int rate, int channels, int family, int *error) {
OggOpusEnc *enc;
struct StdioObject *obj;
obj = malloc(sizeof(*obj));
- enc = ope_create_callbacks(&stdio_callbacks, obj, comments, rate, channels, family, error);
+ enc = ope_encoder_create_callbacks(&stdio_callbacks, obj, comments, rate, channels, family, error);
if (enc == NULL || (error && *error)) {
return NULL;
}
@@ -261,7 +261,7 @@
obj->file = fopen(path, "wb");
if (!obj->file) {
if (error) *error = OPE_CANNOT_OPEN;
- ope_destroy(enc);
+ ope_encoder_destroy(enc);
return NULL;
}
return enc;
@@ -298,7 +298,7 @@
}
/* Create a new OggOpus file (callback-based). */
-OggOpusEnc *ope_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
+OggOpusEnc *ope_encoder_create_callbacks(const OpusEncCallbacks *callbacks, void *user_data,
const OggOpusComments *comments, int rate, int channels, int family, int *error) {
OpusMSEncoder *st=NULL;
OggOpusEnc *enc=NULL;
@@ -385,8 +385,8 @@
}
/* Create a new OggOpus stream, pulling one page at a time. */
-OPE_EXPORT OggOpusEnc *ope_create_pull(const OggOpusComments *comments, int rate, int channels, int family, int *error) {
- OggOpusEnc *enc = ope_create_callbacks(NULL, NULL, comments, rate, channels, family, error);
+OPE_EXPORT OggOpusEnc *ope_encoder_create_pull(const OggOpusComments *comments, int rate, int channels, int family, int *error) {
+ OggOpusEnc *enc = ope_encoder_create_callbacks(NULL, NULL, comments, rate, channels, family, error);
enc->pull_api = 1;
return enc;
}
@@ -599,7 +599,7 @@
}
/* Add/encode any number of float samples to the file. */
-int ope_write_float(OggOpusEnc *enc, const float *pcm, int samples_per_channel) {
+int ope_encoder_write_float(OggOpusEnc *enc, const float *pcm, int samples_per_channel) {
int channels = enc->channels;
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
enc->last_stream->header_is_frozen = 1;
@@ -634,7 +634,7 @@
#define CONVERT_BUFFER 256
/* Add/encode any number of int16 samples to the file. */
-int ope_write(OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel) {
+int ope_encoder_write(OggOpusEnc *enc, const opus_int16 *pcm, int samples_per_channel) {
int channels = enc->channels;
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
enc->last_stream->header_is_frozen = 1;
@@ -671,7 +671,7 @@
}
/* Get the next page from the stream. Returns 1 if there is a page available, 0 if not. */
-OPE_EXPORT int ope_get_page(OggOpusEnc *enc, unsigned char **page, int *len, int flush) {
+OPE_EXPORT int ope_encoder_get_page(OggOpusEnc *enc, unsigned char **page, int *len, int flush) {
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
if (!enc->pull_api) return 0;
else {
@@ -682,7 +682,7 @@
static void extend_signal(float *x, int before, int after, int channels);
-int ope_drain(OggOpusEnc *enc) {
+int ope_encoder_drain(OggOpusEnc *enc) {
int pad_samples;
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
/* Check if it's already been drained. */
@@ -703,7 +703,7 @@
return OPE_OK;
}
-void ope_destroy(OggOpusEnc *enc) {
+void ope_encoder_destroy(OggOpusEnc *enc) {
EncStream *stream;
stream = enc->streams;
while (stream != NULL) {
@@ -723,13 +723,13 @@
}
/* Ends the stream and create a new stream within the same file. */
-int ope_chain_current(OggOpusEnc *enc, const OggOpusComments *comments) {
+int ope_encoder_chain_current(OggOpusEnc *enc, const OggOpusComments *comments) {
enc->last_stream->close_at_end = 0;
- return ope_continue_new_callbacks(enc, enc->last_stream->user_data, comments);
+ return ope_encoder_continue_new_callbacks(enc, enc->last_stream->user_data, comments);
}
/* Ends the stream and create a new file. */
-int ope_continue_new_file(OggOpusEnc *enc, const char *path, const OggOpusComments *comments) {
+int ope_encoder_continue_new_file(OggOpusEnc *enc, const char *path, const OggOpusComments *comments) {
int ret;
struct StdioObject *obj;
if (!(obj = malloc(sizeof(*obj)))) return OPE_ALLOC_FAIL;
@@ -739,7 +739,7 @@
/* By trying to open the file first, we can recover if we can't open it. */
return OPE_CANNOT_OPEN;
}
- ret = ope_continue_new_callbacks(enc, obj, comments);
+ ret = ope_encoder_continue_new_callbacks(enc, obj, comments);
if (ret == OPE_OK) return ret;
fclose(obj->file);
free(obj);
@@ -747,7 +747,7 @@
}
/* Ends the stream and create a new file (callback-based). */
-int ope_continue_new_callbacks(OggOpusEnc *enc, void *user_data, const OggOpusComments *comments) {
+int ope_encoder_continue_new_callbacks(OggOpusEnc *enc, void *user_data, const OggOpusComments *comments) {
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
EncStream *new_stream;
assert(enc->streams);
@@ -760,7 +760,7 @@
return OPE_OK;
}
-int ope_flush_header(OggOpusEnc *enc) {
+int ope_encoder_flush_header(OggOpusEnc *enc) {
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
if (enc->last_stream->header_is_frozen) return OPE_TOO_LATE;
if (enc->last_stream->stream_is_init) return OPE_TOO_LATE;