Skip to content

Commit 3d4e83e

Browse files
committed
Revert "Add notification flow and shutdown handling in SDK (OpenVisualCloud#393)"
The commit is cherry-picked to the zero-copy branch as part of a separate feature development. This reverts commit b7dcb20.
1 parent b7dcb20 commit 3d4e83e

32 files changed

+153
-1133
lines changed

docs/SDK_API_Definition.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,9 @@ NOTE: The codes are negative integer values.
441441
| `-MESH_ERR_BAD_CONFIG_PTR` | Bad configuration pointer | The configuration pointer is NULL. |
442442
| `-MESH_ERR_BAD_BUF_PTR` | Bad buffer pointer | The buffer pointer is NULL. |
443443
| `-MESH_ERR_BAD_BUF_LEN` | Bad buffer length | **Rx connection**: The buffer length is corrupted.<br>**Tx connection**: The buffer length is bigger than maximum. |
444-
| `-MESH_ERR_CLIENT_FAILED` | Client creation failed | An error occurred while creating an SDK client. |
445444
| `-MESH_ERR_CLIENT_CONFIG_INVAL` | Invalid client config | JSON client configuration string is malformed. |
446445
| `-MESH_ERR_MAX_CONN` | Reached max connections number | An attempt to create a connection failed due to reaching the maximum number of connections defined in `"maxMediaConnections"`. |
447-
| `-MESH_ERR_FOUND_ALLOCATED` | Found allocated resources | When deleting an SDK client, some connections were found not closed. Delete all connections explicitly before deleting the client. |
446+
| `-MESH_ERR_FOUND_ALLOCATED` | Found allocated resources | When deleting a client, some connections were found not closed. Delete all connections explicitly before deleting the client. |
448447
| `-MESH_ERR_CONN_FAILED` | Connection creation failed | An error occurred while creating a connection. |
449448
| `-MESH_ERR_CONN_CONFIG_INVAL` | Invalid connection config | JSON connection configuration string is malformed or one of parameters has an incorrect value. |
450449
| `-MESH_ERR_CONN_CONFIG_INCOMPAT` | Incompatible connection config | Incompatible parameters found in the JSON connection configuration string. |

ffmpeg-plugin/mcm_audio_rx.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,19 @@ static int mcm_audio_read_packet(AVFormatContext* avctx, AVPacket* pkt)
133133
s->first_frame = false;
134134

135135
err = mesh_get_buffer_timeout(s->conn, &buf, timeout);
136-
if (err == -MESH_ERR_CONN_CLOSED)
137-
return AVERROR_EOF;
138-
136+
if (err == -MESH_ERR_CONN_CLOSED) {
137+
ret = AVERROR_EOF;
138+
goto error_close_conn;
139+
}
139140
if (err) {
140141
if (mcm_shutdown_requested()) {
141-
return AVERROR_EXIT;
142+
ret = AVERROR_EXIT;
142143
} else {
143144
av_log(avctx, AV_LOG_ERROR, "Get buffer error: %s (%d)\n",
144145
mesh_err2str(err), err);
145-
return AVERROR(EIO);
146+
ret = AVERROR(EIO);
146147
}
148+
goto error_close_conn;
147149
}
148150

149151
if (mcm_shutdown_requested()) {
@@ -164,14 +166,21 @@ static int mcm_audio_read_packet(AVFormatContext* avctx, AVPacket* pkt)
164166
if (err) {
165167
av_log(avctx, AV_LOG_ERROR, "Put buffer error: %s (%d)\n",
166168
mesh_err2str(err), err);
167-
return AVERROR(EIO);
169+
ret = AVERROR(EIO);
170+
goto error_close_conn;
168171
}
169172

170173
return len;
171174

172175
error_put_buf:
173176
mesh_put_buffer(&buf);
174177

178+
error_close_conn:
179+
err = mesh_delete_connection(&s->conn);
180+
if (err)
181+
av_log(avctx, AV_LOG_ERROR, "Delete mesh connection failed: %s (%d)\n",
182+
mesh_err2str(err), err);
183+
175184
return ret;
176185
}
177186

ffmpeg-plugin/mcm_video_rx.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,19 @@ static int mcm_video_read_packet(AVFormatContext* avctx, AVPacket* pkt)
128128
s->first_frame = false;
129129

130130
err = mesh_get_buffer_timeout(s->conn, &buf, timeout);
131-
if (err == -MESH_ERR_CONN_CLOSED)
132-
return AVERROR_EOF;
133-
131+
if (err == -MESH_ERR_CONN_CLOSED) {
132+
ret = AVERROR_EOF;
133+
goto error_close_conn;
134+
}
134135
if (err) {
135136
if (mcm_shutdown_requested()) {
136-
return AVERROR_EXIT;
137+
ret = AVERROR_EXIT;
137138
} else {
138139
av_log(avctx, AV_LOG_ERROR, "Get buffer error: %s (%d)\n",
139140
mesh_err2str(err), err);
140-
return AVERROR(EIO);
141+
ret = AVERROR(EIO);
141142
}
143+
goto error_close_conn;
142144
}
143145

144146
if (mcm_shutdown_requested()) {
@@ -159,14 +161,18 @@ static int mcm_video_read_packet(AVFormatContext* avctx, AVPacket* pkt)
159161
if (err) {
160162
av_log(avctx, AV_LOG_ERROR, "Put buffer error: %s (%d)\n",
161163
mesh_err2str(err), err);
162-
return AVERROR(EIO);
164+
ret = AVERROR(EIO);
165+
goto error_close_conn;
163166
}
164167

165168
return len;
166169

167170
error_put_buf:
168171
mesh_put_buffer(&buf);
169172

173+
error_close_conn:
174+
mesh_delete_connection(&s->conn);
175+
170176
return ret;
171177
}
172178

media-proxy/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ endif()
6666

6767
# Define the .proto files
6868
set(PROTO_FILES
69-
${PROTO_DIR}/type.proto
7069
${PROTO_DIR}/conn-config.proto
7170
${PROTO_DIR}/sdk.proto
7271
${PROTO_DIR}/mediaproxy.proto

media-proxy/include/mesh/client.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

media-proxy/include/mesh/client_registry.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

media-proxy/include/mesh/conn.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ class Connection : public telemetry::MetricsProvider {
206206
Connection * link();
207207

208208
void set_config(const Config& cfg);
209-
void set_parent(const std::string& parent_id);
210-
211-
void notify_parent_conn_unlink_requested(context::Context& ctx);
212209

213210
Result establish(context::Context& ctx);
214211
Result establish_async(context::Context& ctx);
@@ -230,7 +227,6 @@ class Connection : public telemetry::MetricsProvider {
230227
} info;
231228

232229
Config config;
233-
std::string legacy_sdk_id;
234230

235231
protected:
236232
void set_state(context::Context& ctx, State new_state);
@@ -272,7 +268,6 @@ class Connection : public telemetry::MetricsProvider {
272268
context::Context establish_ctx = context::WithCancel(context::Background());
273269
std::jthread establish_th;
274270
std::jthread shutdown_th;
275-
std::string parent_id;
276271
};
277272

278273
const char * kind2str(Kind kind, bool brief = false);

media-proxy/include/mesh/conn_registry.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ class Registry {
5757
return ids;
5858
}
5959

60-
int size() {
61-
std::shared_lock lk(mx);
62-
return conns.size();
63-
}
64-
6560
private:
6661
std::unordered_map<std::string, Connection *> conns;
6762

@@ -73,6 +68,8 @@ class Registry {
7368
std::shared_mutex mx;
7469
};
7570

71+
extern Registry registry;
72+
7673
} // namespace mesh::connection
7774

7875
#endif // CONN_REGISTRY_H

media-proxy/include/mesh/event.h

Lines changed: 0 additions & 108 deletions
This file was deleted.

media-proxy/include/mesh/manager_local.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ namespace mesh::connection {
1717
class LocalManager {
1818
public:
1919
int create_connection_sdk(context::Context& ctx, std::string& id,
20-
const std::string& client_id, mcm_conn_param *param,
21-
memif_conn_param *memif_param,
20+
mcm_conn_param *param, memif_conn_param *memif_param,
2221
const Config& conn_config, std::string& err_str);
2322

24-
Result activate_connection_sdk(context::Context& ctx, const std::string& id);
23+
int activate_connection_sdk(context::Context& ctx, const std::string& id);
2524

2625
int delete_connection_sdk(context::Context& ctx, const std::string& id,
2726
bool do_unregister = true);
@@ -30,8 +29,6 @@ class LocalManager {
3029

3130
int reregister_all_connections(context::Context& ctx);
3231

33-
int notify_all_shutdown_wait(context::Context& ctx);
34-
3532
void shutdown(context::Context& ctx);
3633

3734
void lock();

0 commit comments

Comments
 (0)