Android Media Framework

Android APIs for media playback: MediaPlayer and MediaCodec. MediaPlayer mediaPlayer.setDataSource(path); //fd or url mediaPlayer.setDisplay(SurfaceHolder sh); //SurfaceView or VideoView mediaPlayer.prepare(); // MediaPlayer.start(); // MediaCodec /* init use MediaExtractor to get mime data create decoder by mime type configure decoder by video format and surface view */ MediaExtractor mExtractor; MediaCodec mDecoder; mExtractor = new MediaExtractor(); mExtractor.setDataSource(filePath); MediaFormat format = mExtractor.getTrackFormat(track_index); String mime = format.getString(MediaFormat.KEY_MIME); if mime.startsWith("video/") mExtractor.selectTrack(track_index); mDecoder = MediaCodec.createDecoderByType(mime); mDecoder.configure(format, surface, null, 0 /* Decoder */); mDecoder.start(); /*run start decode video, fill / empty buffer */ MediaCodecExample ...

June 16, 2016 · 3 min · oopsmonk

Android build error on Ubuntu 16.04 LTS

After update system from Ubuntu 14.04 to 16.04, I got some problems, when I was building Android source code. openjdk-7-jdk is gone Add PPA for OpenJDK7 sudo add-apt-repository ppa:openjdk-r/ppa sudo apt remove openjdk-* icedtea-* icedtea6-* sudo apt update && sudo apt install openjdk-7-jdk git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven If you have other java version in system, make sure your java version is correct. ...

June 7, 2016 · 2 min · oopsmonk

Android Full Disk Encryption Workflow (default encryption)

This study is based on Android Marshmallow. Android full disk encryption use dm-crypt, which works with block devices. Please refer to the following docs for more detail: Full Disk Encryption How to setup full disk encryption Android support forceencrypt and encryptable encryption flags, and only support ext4 and f2fs file systems. Setup forceencrypt fstab.bullhead: /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,forceencrypt=/dev/block/platform/soc.0/f9824900.sdhci/by-name/metadata Setup encryptable fstab.hammerhead: /dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,encryptable=/dev/block/platform/msm_sdcc.1/by-name/metadata Related Properties and source code location Related source code: ...

April 29, 2016 · 3 min · oopsmonk

LibCEC on Raspberry Pi

Install requirements sudo apt-get install build-essential autoconf liblockdev1-dev \ libudev-dev git libtool pkg-config cmake libxrandr-dev -y Python and Swing support (Optional) sudo apt-get install python-dev swig -y Checkout and build libcec source code The current version is libcec-3.0.1, but I got an error as follows: make[2]: *** No rule to make target '1', needed by 'src/libcec/libcec.so.3.0.1'. Stop. Using libcec-3.0.0 instead of libcec-3.0.1, it’s work properly. git clone https://github.com/Pulse-Eight/libcec.git cd libcec git checkout libcec-3.0.0 -b cec3.0.0 Checkout platform source ...

November 3, 2015 · 11 min · oopsmonk

Firefox is Really Slow

Firefox is extremely slow on my system, include menu, right-click, tab opening…etc. Mozilla Firefox 40.0 Xubuntu 14.04 LTS 64-bit Linux 3.16.0-45-generic #60~14.04.1-Ubuntu SMP Fri Jul 24 21:16:23 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux After I turned off hardware acceleration, everything is fine. Type this in the browser’s address bar to trun it off: about:preferences#advanced

August 18, 2015 · 1 min · oopsmonk

Markdown Preview Use Sublime Text 3

Download Sublime Text 3 http://www.sublimetext.com/3 Install Package Control https://packagecontrol.io/installation#st3 Use Ctrl + ` or View > Show Console open the Sublime Text console. Copy the text into console and press Enter to install Package Control. Once finished installation, restart Sublime. Install Markdown Preview package Open command palette via Ctrl + Shift + p or Preferences > Package Control from menu. After typing install and press Enter, it will pop-up a package menu. ...

August 12, 2015 · 1 min · oopsmonk

Drawing IP Geolocation on World Map

I found some mystery visitors in nginx’s access log. I tried to figure out the location of those visitors and what they did. IP collection First copy nginx’s access log to a folder and save all logs into a single file. $ mkdir mysteryIPs && cd $_ $ sudo cp /var/log/nginx/access.log.* . $ zcat access.log.* > access-gz.log $ cat access.log.1 >> access-gz.log $ cat access.log >> access-gz.log Remove LAN accesses from log file, for example my subnet IP rang is 192.168.x.x ...

August 1, 2015 · 4 min · oopsmonk