[Asterisk-code-review] format: Register format-attribute module with cached formats. (asterisk[master])

Alexander Traud asteriskteam at digium.com
Wed Nov 11 07:08:52 CST 2015


Alexander Traud has uploaded a new change for review.

  https://gerrit.asterisk.org/1600

Change subject: format: Register format-attribute module with cached formats.
......................................................................

format: Register format-attribute module with cached formats.

In Asterisk 13, cached formats are created before their corresponding format-
attribute module is registered. Cached formats are involved when a local
extension is called. Therefore, ast_format_generate_sdp_fmtp did not work
on local extensions. This change affects the Opus Codec, H.263 (Plus), H.264,
and format-attribute modules provided externally.

ASTERISK-25160 #close

Change-Id: I1ea1f0483e5261e2a050112e4ebdfc22057d1354
---
M main/format.c
1 file changed, 7 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/1600/1

diff --git a/main/format.c b/main/format.c
index b9931e5..1582161 100644
--- a/main/format.c
+++ b/main/format.c
@@ -34,6 +34,7 @@
 #include "asterisk/logger.h"
 #include "asterisk/codec.h"
 #include "asterisk/format.h"
+#include "asterisk/format_cache.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"
 #include "asterisk/module.h"
@@ -136,6 +137,7 @@
 {
 	SCOPED_AO2WRLOCK(lock, interfaces);
 	struct format_interface *format_interface;
+	struct ast_format *cached;
 
 	if (!interface->format_clone || !interface->format_destroy) {
 		ast_log(LOG_ERROR, "Format interface for codec '%s' does not implement required callbacks\n", codec);
@@ -156,6 +158,11 @@
 	}
 	format_interface->interface = interface;
 	strcpy(format_interface->codec, codec); /* Safe */
+
+	cached = ast_format_cache_get(codec);
+	if (cached) {
+		cached->interface = format_interface->interface;
+	}
 
 	/* Once registered a format interface cannot be unregistered. */
 	ast_module_shutdown_ref(mod);
@@ -283,14 +290,6 @@
 {
 	const struct ast_format_interface *interface = format->interface;
 
-	if (!interface) {
-		struct format_interface *format_interface = ao2_find(interfaces, format->codec->name, OBJ_SEARCH_KEY);
-		if (format_interface) {
-			interface = format_interface->interface;
-			ao2_ref(format_interface, -1);
-		}
-	}
-
 	if (!interface || !interface->format_attribute_set) {
 		return ao2_bump((struct ast_format*)format);
 	}
@@ -312,14 +311,6 @@
 struct ast_format *ast_format_parse_sdp_fmtp(const struct ast_format *format, const char *attributes)
 {
 	const struct ast_format_interface *interface = format->interface;
-
-	if (!interface) {
-		struct format_interface *format_interface = ao2_find(interfaces, format->codec->name, OBJ_SEARCH_KEY);
-		if (format_interface) {
-			interface = format_interface->interface;
-			ao2_ref(format_interface, -1);
-		}
-	}
 
 	if (!interface || !interface->format_parse_sdp_fmtp) {
 		return ao2_bump((struct ast_format*)format);

-- 
To view, visit https://gerrit.asterisk.org/1600
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ea1f0483e5261e2a050112e4ebdfc22057d1354
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>



More information about the asterisk-code-review mailing list