<p>sungtae kim has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10986">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Added creation timestamp for the bridge<br><br>Added creation timestamp for the bridge. This small feature will<br>help to checking the bridge's status to figure out which bridge is<br>in old/zombie or not. Also added detail items for the 'bridge show *'<br>cli to provide more detail info. And added creation item to the ARI<br>as well.<br><br>Change-Id: I460238c488eca4d216b9176576211cb03286e040<br>---<br>M include/asterisk/bridge.h<br>M main/bridge.c<br>M main/stasis_bridges.c<br>M rest-api/api-docs/bridges.json<br>4 files changed, 33 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/10986/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/bridge.h b/include/asterisk/bridge.h</span><br><span>index e4d11e8..8fe9f0e 100644</span><br><span>--- a/include/asterisk/bridge.h</span><br><span>+++ b/include/asterisk/bridge.h</span><br><span>@@ -329,6 +329,8 @@</span><br><span> unsigned int num_channels;</span><br><span> /*! Number of active channels in the bridge. */</span><br><span> unsigned int num_active;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! The time of bridge creation */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct timeval creationtime;</span><br><span> /*! The video mode of the bridge */</span><br><span> enum ast_bridge_video_mode_type video_mode;</span><br><span> };</span><br><span>@@ -390,6 +392,8 @@</span><br><span> AST_STRING_FIELD(uniqueid);</span><br><span> );</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /*! The time of bridge creation */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct timeval creationtime;</span><br><span> /*! Type mapping used for media routing */</span><br><span> struct ast_vector_int media_types;</span><br><span> /*! Current bridge snapshot */</span><br><span>diff --git a/main/bridge.c b/main/bridge.c</span><br><span>index 1bee2e6..5752001 100644</span><br><span>--- a/main/bridge.c</span><br><span>+++ b/main/bridge.c</span><br><span>@@ -822,6 +822,8 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ self->creationtime = ast_tvnow();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return self;</span><br><span> }</span><br><span> </span><br><span>@@ -5051,8 +5053,8 @@</span><br><span> </span><br><span> static char *handle_bridge_show_all(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-#define FORMAT_HDR "%-36s %5s %-15s %s\n"</span><br><span style="color: hsl(0, 100%, 40%);">-#define FORMAT_ROW "%-36s %5u %-15s %s\n"</span><br><span style="color: hsl(120, 100%, 40%);">+#define FORMAT_HDR "%-36s %5s %-15s %-15s %s\n"</span><br><span style="color: hsl(120, 100%, 40%);">+#define FORMAT_ROW "%-36s %5u %-15s %-15s %s\n"</span><br><span> </span><br><span> struct ao2_iterator iter;</span><br><span> struct ast_bridge *bridge;</span><br><span>@@ -5068,18 +5070,22 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_cli(a->fd, FORMAT_HDR, "Bridge-ID", "Chans", "Type", "Technology");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, FORMAT_HDR, "Bridge-ID", "Chans", "Type", "Technology", "Duration");</span><br><span> </span><br><span> iter = ao2_iterator_init(bridges, 0);</span><br><span> for (; (bridge = ao2_iterator_next(&iter)); ao2_ref(bridge, -1)) {</span><br><span> struct ast_bridge_snapshot *snapshot = ast_bridge_get_snapshot(bridge);</span><br><span style="color: hsl(120, 100%, 40%);">+ char print_time[32];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_duration_hh_mm_ss(ast_tvnow().tv_sec - snapshot->creationtime.tv_sec, print_time, sizeof(print_time));</span><br><span> </span><br><span> if (snapshot) {</span><br><span> ast_cli(a->fd, FORMAT_ROW,</span><br><span> snapshot->uniqueid,</span><br><span> snapshot->num_channels,</span><br><span> S_OR(snapshot->subclass, "<unknown>"),</span><br><span style="color: hsl(0, 100%, 40%);">- S_OR(snapshot->technology, "<unknown>"));</span><br><span style="color: hsl(120, 100%, 40%);">+ S_OR(snapshot->technology, "<unknown>"),</span><br><span style="color: hsl(120, 100%, 40%);">+ print_time);</span><br><span> ao2_ref(snapshot, -1);</span><br><span> }</span><br><span> }</span><br><span>@@ -5112,6 +5118,7 @@</span><br><span> static char *handle_bridge_show_specific(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span> struct ast_bridge_snapshot *snapshot;</span><br><span style="color: hsl(120, 100%, 40%);">+ char print_time[32];</span><br><span> </span><br><span> switch (cmd) {</span><br><span> case CLI_INIT:</span><br><span>@@ -5136,10 +5143,19 @@</span><br><span> ast_cli(a->fd, "Bridge '%s' not found\n", a->argv[2]);</span><br><span> return CLI_SUCCESS;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_duration_hh_mm_ss(ast_tvnow().tv_sec - snapshot->creationtime.tv_sec, print_time, sizeof(print_time));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_cli(a->fd, "Id: %s\n", snapshot->uniqueid);</span><br><span> ast_cli(a->fd, "Type: %s\n", S_OR(snapshot->subclass, "<unknown>"));</span><br><span> ast_cli(a->fd, "Technology: %s\n", S_OR(snapshot->technology, "<unknown>"));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Subclass: %s\n", snapshot->subclass);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Creator: %s\n", snapshot->creator);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Name: %s\n", snapshot->name);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Video-Source-Id: %s\n", snapshot->video_source_id);</span><br><span> ast_cli(a->fd, "Num-Channels: %u\n", snapshot->num_channels);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Num-Active: %u\n", snapshot->num_active);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Duration: %s\n", print_time);</span><br><span> ao2_callback(snapshot->channels, OBJ_NODATA, bridge_show_specific_print_channel, a);</span><br><span> ao2_ref(snapshot, -1);</span><br><span> </span><br><span>diff --git a/main/stasis_bridges.c b/main/stasis_bridges.c</span><br><span>index bed28ba..cfdf117 100644</span><br><span>--- a/main/stasis_bridges.c</span><br><span>+++ b/main/stasis_bridges.c</span><br><span>@@ -246,6 +246,7 @@</span><br><span> snapshot->capabilities = bridge->technology->capabilities;</span><br><span> snapshot->num_channels = bridge->num_channels;</span><br><span> snapshot->num_active = bridge->num_active;</span><br><span style="color: hsl(120, 100%, 40%);">+ snapshot->creationtime = bridge->creationtime;</span><br><span> snapshot->video_mode = bridge->softmix.video_mode.mode;</span><br><span> if (snapshot->video_mode == AST_BRIDGE_VIDEO_MODE_SINGLE_SRC</span><br><span> && bridge->softmix.video_mode.mode_data.single_src_data.chan_vsrc) {</span><br><span>@@ -679,7 +680,7 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- json_bridge = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: o, s: s}",</span><br><span style="color: hsl(120, 100%, 40%);">+ json_bridge = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: o, s: o, s: s}",</span><br><span> "id", snapshot->uniqueid,</span><br><span> "technology", snapshot->technology,</span><br><span> "bridge_type", capability2str(snapshot->capabilities),</span><br><span>@@ -687,6 +688,7 @@</span><br><span> "creator", snapshot->creator,</span><br><span> "name", snapshot->name,</span><br><span> "channels", json_channels,</span><br><span style="color: hsl(120, 100%, 40%);">+ "creationtime", ast_json_timeval(snapshot->creationtime, NULL),</span><br><span> "video_mode", ast_bridge_video_mode_to_string(snapshot->video_mode));</span><br><span> if (!json_bridge) {</span><br><span> return NULL;</span><br><span>diff --git a/rest-api/api-docs/bridges.json b/rest-api/api-docs/bridges.json</span><br><span>index 04416c1..2368a98 100644</span><br><span>--- a/rest-api/api-docs/bridges.json</span><br><span>+++ b/rest-api/api-docs/bridges.json</span><br><span>@@ -753,7 +753,12 @@</span><br><span> "type": "string",</span><br><span> "description": "The ID of the channel that is the source of video in this bridge, if one exists.",</span><br><span> "required": false</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span style="color: hsl(120, 100%, 40%);">+ "creationtime": {</span><br><span style="color: hsl(120, 100%, 40%);">+ "required": true,</span><br><span style="color: hsl(120, 100%, 40%);">+ "type": "Date",</span><br><span style="color: hsl(120, 100%, 40%);">+ "description": "Timestamp when bridge was created"</span><br><span style="color: hsl(120, 100%, 40%);">+ },</span><br><span> }</span><br><span> }</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10986">change 10986</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10986"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I460238c488eca4d216b9176576211cb03286e040 </div>
<div style="display:none"> Gerrit-Change-Number: 10986 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>