[Asterisk-code-review] codecs: Remove test-law. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Mon Jan 4 05:00:59 CST 2021


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15206 )

Change subject: codecs: Remove test-law.
......................................................................

codecs: Remove test-law.

This was dead code, test code introduced with Asterisk 13. This was
found while analyzing ASTERISK_28416 and ASTERISK_29185. This change
partly fixes, not closes those two issues.

Change-Id: I42d0daa37f6f334c7d86672f06f085858a3f3940
---
M channels/iax2/codec_pref.c
M channels/iax2/format_compatibility.c
M codecs/codec_ulaw.c
M include/asterisk/format_cache.h
M include/asterisk/format_compatibility.h
M main/codec_builtin.c
M main/format_cache.c
M main/format_compatibility.c
8 files changed, 2 insertions(+), 80 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, approved; Approved for Submit
  Kevin Harwell: Looks good to me, but someone else must approve



diff --git a/channels/iax2/codec_pref.c b/channels/iax2/codec_pref.c
index 7811ca8..684f921 100644
--- a/channels/iax2/codec_pref.c
+++ b/channels/iax2/codec_pref.c
@@ -348,7 +348,7 @@
 	AST_FORMAT_T140,
 	AST_FORMAT_SIREN7,
 	AST_FORMAT_SIREN14,
-	AST_FORMAT_TESTLAW,
+	0, /* reserved; was AST_FORMAT_TESTLAW */
 	AST_FORMAT_G719,
 	0, /* Place holder */
 	0, /* Place holder */
diff --git a/channels/iax2/format_compatibility.c b/channels/iax2/format_compatibility.c
index 1543792..2325dd8 100644
--- a/channels/iax2/format_compatibility.c
+++ b/channels/iax2/format_compatibility.c
@@ -91,7 +91,6 @@
 		AST_FORMAT_G719,
 		AST_FORMAT_SIREN14,
 		AST_FORMAT_SIREN7,
-		AST_FORMAT_TESTLAW,
 		/*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
 		AST_FORMAT_G722,
 		/*! Okay, well, signed linear is easy to translate into other stuff */
diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c
index 609d06d..00a0916 100644
--- a/codecs/codec_ulaw.c
+++ b/codecs/codec_ulaw.c
@@ -97,25 +97,6 @@
 	.buf_size = BUFFER_SAMPLES * 2,
 };
 
-static struct ast_translator testlawtolin = {
-	.name = "testlawtolin",
-	.src_codec = {
-		.name = "testlaw",
-		.type = AST_MEDIA_TYPE_AUDIO,
-		.sample_rate = 8000,
-	},
-	.dst_codec = {
-		.name = "slin",
-		.type = AST_MEDIA_TYPE_AUDIO,
-		.sample_rate = 8000,
-	},
-	.format = "slin",
-	.framein = ulawtolin_framein,
-	.sample = ulaw_sample,
-	.buffer_samples = BUFFER_SAMPLES,
-	.buf_size = BUFFER_SAMPLES * 2,
-};
-
 /*!
  * \brief The complete translator for LinToulaw.
  */
@@ -139,33 +120,12 @@
 	.buffer_samples = BUFFER_SAMPLES,
 };
 
-static struct ast_translator lintotestlaw = {
-	.name = "lintotestlaw",
-	.src_codec = {
-		.name = "slin",
-		.type = AST_MEDIA_TYPE_AUDIO,
-		.sample_rate = 8000,
-	},
-	.dst_codec = {
-		.name = "testlaw",
-		.type = AST_MEDIA_TYPE_AUDIO,
-		.sample_rate = 8000,
-	},
-	.format = "testlaw",
-	.framein = lintoulaw_framein,
-	.sample = slin8_sample,
-	.buf_size = BUFFER_SAMPLES,
-	.buffer_samples = BUFFER_SAMPLES,
-};
-
 static int unload_module(void)
 {
 	int res;
 
 	res = ast_unregister_translator(&lintoulaw);
 	res |= ast_unregister_translator(&ulawtolin);
-	res |= ast_unregister_translator(&testlawtolin);
-	res |= ast_unregister_translator(&lintotestlaw);
 
 	return res;
 }
@@ -176,8 +136,6 @@
 
 	res = ast_register_translator(&ulawtolin);
 	res |= ast_register_translator(&lintoulaw);
-	res |= ast_register_translator(&lintotestlaw);
-	res |= ast_register_translator(&testlawtolin);
 
 	if (res) {
 		unload_module();
diff --git a/include/asterisk/format_cache.h b/include/asterisk/format_cache.h
index 7dc0276..33033da 100644
--- a/include/asterisk/format_cache.h
+++ b/include/asterisk/format_cache.h
@@ -84,11 +84,6 @@
 extern struct ast_format *ast_format_alaw;
 
 /*!
- * \brief Built-in cached testlaw format.
- */
-extern struct ast_format *ast_format_testlaw;
-
-/*!
  * \brief Built-in cached gsm format.
  */
 extern struct ast_format *ast_format_gsm;
diff --git a/include/asterisk/format_compatibility.h b/include/asterisk/format_compatibility.h
index 0420ec6..e6a99b3 100644
--- a/include/asterisk/format_compatibility.h
+++ b/include/asterisk/format_compatibility.h
@@ -72,7 +72,7 @@
 /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */
 #define AST_FORMAT_OPUS (1ULL << 34)
 /*! Raw testing-law data (G.711) */
-#define AST_FORMAT_TESTLAW (1ULL << 47)
+/* #define AST_FORMAT_TESTLAW (1ULL << 47) */
 /*! H.261 Video */
 #define AST_FORMAT_H261 (1ULL << 18)
 /*! H.263 Video */
diff --git a/main/codec_builtin.c b/main/codec_builtin.c
index ce65754..c1ae685 100644
--- a/main/codec_builtin.c
+++ b/main/codec_builtin.c
@@ -702,20 +702,6 @@
 	.get_length = siren14_length,
 };
 
-static struct ast_codec testlaw = {
-	.name = "testlaw",
-	.description = "G.711 test-law",
-	.type = AST_MEDIA_TYPE_AUDIO,
-	.sample_rate = 8000,
-	.minimum_ms = 10,
-	.maximum_ms = 150,
-	.default_ms = 20,
-	.minimum_bytes = 80,
-	.samples_count = ulaw_samples,
-	.get_length = ulaw_length,
-	.smooth = 1,
-};
-
 static int g719_samples(struct ast_frame *frame)
 {
 	return (int) frame->datalen * ((float) 48000 / 8000);
@@ -969,7 +955,6 @@
 	res |= CODEC_REGISTER_AND_CACHE(g722);
 	res |= CODEC_REGISTER_AND_CACHE(siren7);
 	res |= CODEC_REGISTER_AND_CACHE(siren14);
-	res |= CODEC_REGISTER_AND_CACHE(testlaw);
 	res |= CODEC_REGISTER_AND_CACHE(g719);
 	res |= CODEC_REGISTER_AND_CACHE(opus);
 	res |= CODEC_REGISTER_AND_CACHE(jpeg);
diff --git a/main/format_cache.c b/main/format_cache.c
index 3ce8ee0..f1a7fda 100644
--- a/main/format_cache.c
+++ b/main/format_cache.c
@@ -91,11 +91,6 @@
 struct ast_format *ast_format_alaw;
 
 /*!
- * \brief Built-in cached testlaw format.
- */
-struct ast_format *ast_format_testlaw;
-
-/*!
  * \brief Built-in cached gsm format.
  */
 struct ast_format *ast_format_gsm;
@@ -343,7 +338,6 @@
 	ao2_replace(ast_format_g722, NULL);
 	ao2_replace(ast_format_siren7, NULL);
 	ao2_replace(ast_format_siren14, NULL);
-	ao2_replace(ast_format_testlaw, NULL);
 	ao2_replace(ast_format_g719, NULL);
 	ao2_replace(ast_format_opus, NULL);
 	ao2_replace(ast_format_codec2, NULL);
@@ -434,8 +428,6 @@
 		ao2_replace(ast_format_siren7, format);
 	} else if (!strcmp(name, "siren14")) {
 		ao2_replace(ast_format_siren14, format);
-	} else if (!strcmp(name, "testlaw")) {
-		ao2_replace(ast_format_testlaw, format);
 	} else if (!strcmp(name, "g719")) {
 		ao2_replace(ast_format_g719, format);
 	} else if (!strcmp(name, "opus")) {
diff --git a/main/format_compatibility.c b/main/format_compatibility.c
index 706e1b2..7f2faa7 100644
--- a/main/format_compatibility.c
+++ b/main/format_compatibility.c
@@ -76,8 +76,6 @@
 		return AST_FORMAT_SPEEX16;
 	} else if (ast_format_cmp(format, ast_format_opus) == AST_FORMAT_CMP_EQUAL) {
 		return AST_FORMAT_OPUS;
-	} else if (ast_format_cmp(format, ast_format_testlaw) == AST_FORMAT_CMP_EQUAL) {
-		return AST_FORMAT_TESTLAW;
 	} else if (ast_format_cmp(format, ast_format_h261) == AST_FORMAT_CMP_EQUAL) {
 		return AST_FORMAT_H261;
 	} else if (ast_format_cmp(format, ast_format_h263) == AST_FORMAT_CMP_EQUAL) {
@@ -143,8 +141,6 @@
 		return AST_FORMAT_SPEEX16;
 	} else if (codec->id == ast_format_get_codec_id(ast_format_opus)) {
 		return AST_FORMAT_OPUS;
-	} else if (codec->id == ast_format_get_codec_id(ast_format_testlaw)) {
-		return AST_FORMAT_TESTLAW;
 	} else if (codec->id == ast_format_get_codec_id(ast_format_h261)) {
 		return AST_FORMAT_H261;
 	} else if (codec->id == ast_format_get_codec_id(ast_format_h263)) {
@@ -230,9 +226,6 @@
 	/*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */
 	case AST_FORMAT_OPUS:
 		return ast_format_opus;
-	/*! Raw mu-law data (G.711) */
-	case AST_FORMAT_TESTLAW:
-		return ast_format_testlaw;
 
 	/*! H.261 Video */
 	case AST_FORMAT_H261:

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15206
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I42d0daa37f6f334c7d86672f06f085858a3f3940
Gerrit-Change-Number: 15206
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-CC: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210104/31c16211/attachment-0001.html>


More information about the asterisk-code-review mailing list