]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add t38_options and media_type to rtp term
authorMathieu Rene <mrene@avgs.ca>
Thu, 9 Aug 2012 15:15:07 +0000 (11:15 -0400)
committerMathieu Rene <mrene@avgs.ca>
Thu, 9 Aug 2012 15:15:07 +0000 (11:15 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h

index 9df5e2a2e0c83c1529f4bd823495166a02a3f4f8..63646c4943863e44e61294950644430cf187ae56 100644 (file)
@@ -125,6 +125,9 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
         switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, kRFC2833PT, "%d", term->u.rtp.rfc2833_pt);
         switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, kRATE, "%d", term->u.rtp.rate);
         switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, kCODEC, term->u.rtp.codec);
+        
+        switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, kMEDIATYPE, mg_media_type2str(term->u.rtp.media_type));
+        
     } else if (term->type == MG_TERM_TDM) {
         switch_snprintf(dialstring, sizeof dialstring, "tdm/%s", term->name);
         
index 46f850ff16e94898e543e78d4143049ca3f08747..4285526af39892da124206b2d9806ab051124049 100644 (file)
@@ -79,6 +79,7 @@ typedef struct mg_context_s mg_context_t;
 #define kRFC2833PT "rfc2833_pt"
 #define kMODE "mode"
 #define kRATE "rate"
+#define kMEDIATYPE "media_type"
 
 /* TDM parameters understood by the controllable channel */
 #define kSPAN_ID "span"
@@ -96,6 +97,32 @@ enum {
     
 } mg_termination_flags;
 
+
+typedef enum {
+    MGM_AUDIO = 0,
+    MGM_IMAGE,
+    MGM_INVALID
+} mg_media_type_t;
+
+static inline const char *mg_media_type2str(mg_media_type_t type) {
+    switch (type) {
+        case MGM_AUDIO:
+            return "audio";
+        case MGM_IMAGE:
+            return "image";
+        case MGM_INVALID:
+            return NULL;
+    }
+}
+
+static inline mg_media_type_t mg_media_type_parse(const char *str) {
+    if (!strcasecmp(str, "audio")) {
+        return MGM_AUDIO;
+    } else if (!strcasecmp(str, "image")) {
+        return MGM_IMAGE;
+    }
+}
+
 struct mg_context_s {
     uint32_t context_id;
     mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
@@ -133,6 +160,8 @@ struct mg_termination_s {
             int rate;       /*!< Sampling rate */
             const char *codec; /*!< Codec to use, using the freeswitch nomenclature. This could be "PCMU" for G711.U, "PCMA" for G711.A, or "G729" for g729 */
             int term_id;
+            switch_t38_options_t t38_options;
+            mg_media_type_t media_type;
         } rtp;
         
         struct {