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

Add some overload methods of getXxxMetadata() with charset parameter. #1719

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.io.InputStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
Expand Down Expand Up @@ -543,63 +544,88 @@ public double getVideoFrameRate() {
}

@Override public Map<String, String> getMetadata() {
return this.getMetadata(Charset.defaultCharset());
}

public Map<String, String> getMetadata(Charset charset) {
if (oc == null) {
return super.getMetadata();
}
AVDictionaryEntry entry = null;
Map<String, String> metadata = new HashMap<String, String>();
while ((entry = av_dict_get(oc.metadata(), "", entry, AV_DICT_IGNORE_SUFFIX)) != null) {
metadata.put(entry.key().getString(), entry.value().getString());
metadata.put(entry.key().getString(charset), entry.value().getString(charset));
}
return metadata;
}

@Override public Map<String, String> getVideoMetadata() {
return this.getVideoMetadata(Charset.defaultCharset());
}

public Map<String, String> getVideoMetadata(Charset charset) {
if (video_st == null) {
return super.getVideoMetadata();
}
AVDictionaryEntry entry = null;
Map<String, String> metadata = new HashMap<String, String>();
while ((entry = av_dict_get(video_st.metadata(), "", entry, AV_DICT_IGNORE_SUFFIX)) != null) {
metadata.put(entry.key().getString(), entry.value().getString());
metadata.put(entry.key().getString(charset), entry.value().getString(charset));
}
return metadata;
}

@Override public Map<String, String> getAudioMetadata() {
return this.getAudioMetadata(Charset.defaultCharset());
}

public Map<String, String> getAudioMetadata(Charset charset) {
if (audio_st == null) {
return super.getAudioMetadata();
}
AVDictionaryEntry entry = null;
Map<String, String> metadata = new HashMap<String, String>();
while ((entry = av_dict_get(audio_st.metadata(), "", entry, AV_DICT_IGNORE_SUFFIX)) != null) {
metadata.put(entry.key().getString(), entry.value().getString());
metadata.put(entry.key().getString(charset), entry.value().getString(charset));
}
return metadata;
}


@Override public String getMetadata(String key) {
return this.getMetadata(key, Charset.defaultCharset());
}

public String getMetadata(String key, Charset charset) {
if (oc == null) {
return super.getMetadata(key);
}
AVDictionaryEntry entry = av_dict_get(oc.metadata(), key, null, 0);
return entry == null || entry.value() == null ? null : entry.value().getString();
return entry == null || entry.value() == null ? null : entry.value().getString(charset);
}

@Override public String getVideoMetadata(String key) {
return this.getVideoMetadata(key, Charset.defaultCharset());
}

public String getVideoMetadata(String key, Charset charset) {
if (video_st == null) {
return super.getVideoMetadata(key);
}
AVDictionaryEntry entry = av_dict_get(video_st.metadata(), key, null, 0);
return entry == null || entry.value() == null ? null : entry.value().getString();
return entry == null || entry.value() == null ? null : entry.value().getString(charset);
}

@Override public String getAudioMetadata(String key) {
return this.getAudioMetadata(key, Charset.defaultCharset());
}

public String getAudioMetadata(String key, Charset charset) {
if (audio_st == null) {
return super.getAudioMetadata(key);
}
AVDictionaryEntry entry = av_dict_get(audio_st.metadata(), key, null, 0);
return entry == null || entry.value() == null ? null : entry.value().getString();
return entry == null || entry.value() == null ? null : entry.value().getString(charset);
}

/** default override of super.setFrameNumber implies setting
Expand Down