Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the offset byte stream #11143

Open
Sidnio opened this issue May 1, 2023 · 3 comments
Open

How to set the offset byte stream #11143

Sidnio opened this issue May 1, 2023 · 3 comments
Assignees
Labels

Comments

@Sidnio
Copy link

Sidnio commented May 1, 2023

image

How to set the offset byte stream

I tried to implement it with request headers but it couldn't


 val dataSourceFactory: DataSource.Factory = DataSource.Factory {
            val factory = DefaultHttpDataSource.Factory()

            val dataSource = factory.createDataSource()

            dataSource.setRequestProperty("Range", "bytes=0-1023")

            dataSource;
        }
@marcbaechinger
Copy link
Contributor

The offset tells where the implementation of the DataReader should start writing data into the buffer array that is passed into the method.

A user of the DataReader passes the buffer array that they own and then decide where the data reader should start writing data into the buffer array.

If you implement a DataReader then you only have to set the offset when you are doing a unit test that calls this method. If the DataSource is used as part of the player, this method is called by some component of the player. You don't have to call this yourself as far as I understand.

@Sidnio
Copy link
Author

Sidnio commented May 3, 2023

The tells where the implementation of the should start writing data into the array that is passed into the method.offsetDataReaderbuffer

Yes, how to do it

@marcbaechinger
Copy link
Contributor

I'm afraid but I'm not sure I understand. Like I said, this is probably called by the player that is using your implementation in case you have configured the player accordingly.

Assuming the testee dataReader is created in setUp of your unit test may call:

@Test
public void read() {
   byte[] buffer = new byte[20];
   int offset = 5;
   Arrays.fill(buffer, (byte) 1);

   dataReader.read(buffer, offset, 10);
   
   // assert here only bytes 5 - 15 are overridden by the reader.
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants