+*/
+enum bt_component_status bt_component_sink_set_consume_cb(
+ struct bt_component *component,
+ bt_component_sink_consume_cb consume)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ if (!component->initializing) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ sink->consume = consume;
+end:
+ return ret;
+}
+
+enum bt_component_status bt_component_sink_set_add_iterator_cb(
+ struct bt_component *component,
+ bt_component_sink_add_iterator_cb add_iterator)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ if (!component->initializing) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ sink->add_iterator = add_iterator;
+end:
+ return ret;
+}
+
+enum bt_component_status bt_component_sink_set_minimum_input_count(
+ struct bt_component *component,
+ unsigned int minimum)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ if (!component->initializing) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ sink->input.min_count = minimum;
+end:
+ return ret;
+}
+
+enum bt_component_status bt_component_sink_set_maximum_input_count(
+ struct bt_component *component,
+ unsigned int maximum)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ if (!component->initializing) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ sink->input.max_count = maximum;
+end:
+ return ret;
+}
+
+enum bt_component_status
+bt_component_sink_get_input_count(struct bt_component *component,
+ unsigned int *count)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component || !count) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ *count = (unsigned int) sink->input.iterators->len;
+end:
+ return ret;
+}
+
+enum bt_component_status
+bt_component_sink_get_input_iterator(struct bt_component *component,
+ unsigned int input, struct bt_notification_iterator **iterator)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component || !iterator) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ if (input >= (unsigned int) sink->input.iterators->len) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ *iterator = bt_get(g_ptr_array_index(sink->input.iterators, input));
+end:
+ return ret;
+}
+
+enum bt_component_status
+bt_component_sink_add_iterator(struct bt_component *component,
+ struct bt_notification_iterator *iterator)
+{
+ struct bt_component_sink *sink;
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!component || !iterator) {
+ ret = BT_COMPONENT_STATUS_INVALID;
+ goto end;
+ }
+
+ if (bt_component_get_type(component) != BT_COMPONENT_TYPE_SINK) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ sink = container_of(component, struct bt_component_sink, parent);
+ if (sink->input.iterators->len == sink->input.max_count) {
+ ret = BT_COMPONENT_STATUS_UNSUPPORTED;
+ goto end;
+ }
+
+ if (sink->add_iterator) {
+ ret = sink->add_iterator(component, iterator);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ }
+
+ g_ptr_array_add(sink->input.iterators, bt_get(iterator));
+end:
+ return ret;
+}