* Set a metadata configuration key in a session. * * @param sess The session to configure. Must not be NULL. * @param key The configuration key (SRD_CONF_*). * @param data The new value for the key, as a GVariant with GVariantType * appropriate to that key. A floating reference can be passed * in; its refcount will be sunk and unreferenced after use. * * @return SRD
| 169 | * @since 0.3.0 |
| 170 | */ |
| 171 | SRD_API int srd_session_metadata_set(struct srd_session *sess, int key, |
| 172 | GVariant *data) |
| 173 | { |
| 174 | GSList *l; |
| 175 | int ret; |
| 176 | |
| 177 | if (!sess) |
| 178 | return SRD_ERR_ARG; |
| 179 | |
| 180 | if (!key) { |
| 181 | srd_err("Invalid key."); |
| 182 | return SRD_ERR_ARG; |
| 183 | } |
| 184 | |
| 185 | if (!data) { |
| 186 | srd_err("Invalid value."); |
| 187 | return SRD_ERR_ARG; |
| 188 | } |
| 189 | |
| 190 | /* Hardcoded to samplerate/uint64 for now. */ |
| 191 | |
| 192 | if (key != SRD_CONF_SAMPLERATE) { |
| 193 | srd_err("Unknown config key %d.", key); |
| 194 | return SRD_ERR_ARG; |
| 195 | } |
| 196 | if (!g_variant_is_of_type(data, G_VARIANT_TYPE_UINT64)) { |
| 197 | srd_err("Invalid value type: expected uint64, got %s", |
| 198 | g_variant_get_type_string(data)); |
| 199 | return SRD_ERR_ARG; |
| 200 | } |
| 201 | |
| 202 | srd_dbg("Setting session %d samplerate to %"G_GUINT64_FORMAT".", |
| 203 | sess->session_id, g_variant_get_uint64(data)); |
| 204 | |
| 205 | ret = SRD_OK; |
| 206 | for (l = sess->di_list; l; l = l->next) { |
| 207 | if ((ret = srd_inst_send_meta(l->data, key, data)) != SRD_OK) |
| 208 | break; |
| 209 | } |
| 210 | |
| 211 | g_variant_unref(data); |
| 212 | |
| 213 | return ret; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Send a chunk of logic sample data to a running decoder session. |
no test coverage detected