Skip to content

[Interceptor] Rework Attributes #242

Open
@k0nserv

Description

@k0nserv

Migrated issue from webrtc-rs/interceptor

The signature for RTPReader's read method currently accepts Attributes by reference, but then also returns Attributes. This makes it impossible to avoid at least one clone(in the last step of the interceptor chain).

By changing the type from &Attribute to &mut Attributes and not returning the Attributes i.e. making it an inout value, we can avoid this cloning.

This means that instead of:

    async fn read(
        &self,
        buf: &mut [u8],
        attributes: &Attributes,
    ) -> Result<(usize, Attributes)>;

we'll have:

    async fn read(
        &self,
        buf: &mut [u8],
        attributes: &mut Attributes,
    ) -> Result<usize>;

which results in a single allocation of Attributes.

Further, it should be possible to change the type of Attributes from HashMap<usize, usize> to HashMap<usize, Box<dyn Any>> which allows more freedom in the values stored within.

I'll try and make a PR to this effect at some point, but if someone sees this before then feel free to do it for me :)

EDIT: I'm actually slightly wrong about this, only the clone in the last part of the interceptor chain is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsubcrate:interceptorFor issues specifica to the interceptor crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions