Commit c3b6e837 by sheenachhabra Committed by Tofunmi Adigun-Hameed

Add argument validation in Mp4LocationData

PiperOrigin-RevId: 533121451
(cherry picked from commit 2a411ec23308e19c57672f363a2c0e0781863bf8)
parent 35466ac3
......@@ -15,8 +15,11 @@
*/
package com.google.android.exoplayer2.container;
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.FloatRange;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.common.primitives.Floats;
......@@ -26,8 +29,18 @@ public final class Mp4LocationData implements Metadata.Entry {
public final float latitude;
public final float longitude;
/** Creates an instance. */
public Mp4LocationData(float latitude, float longitude) {
/**
* Creates an instance.
*
* @param latitude The latitude, in degrees. Its value must be in the range [-90, 90].
* @param longitude The longitude, in degrees. Its value must be in the range [-180, 180].
*/
public Mp4LocationData(
@FloatRange(from = -90.0, to = 90.0) float latitude,
@FloatRange(from = -180.0, to = 180.0) float longitude) {
checkArgument(
latitude >= -90.0f && latitude <= 90.0f && longitude >= -180.0f && longitude <= 180.0f,
"Invalid latitude or longitude");
this.latitude = latitude;
this.longitude = longitude;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment