2013年11月14日 星期四

Build WebM for Android on Ubuntu

 本文參考自 http://code.google.com/p/webm/ 中的 README.android
並加入一些操作細節, 以解決 build error

1. Create Android application project

2. Create <project>/jni

3. Change current directory to <project>/jni

4. git clone http://git.chromium.org/webm/bindings.git

5. git clone http://git.chromium.org/webm/libvpx.git

6. ./libvpx/configure --target=armv7-android-gcc --disable-examples -disable-neon --sdk-path=<full path to ndk>

7. Change current directory to <project>/jni/bindings/JNI

8. git clone http://git.chromium.org/webm/libwebm.git

9. Download ogg library from http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz, extract to bindings/JNI

10. cd llibogg-1.3.0 && ./configure && cd..

11. Download libvorbis from http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz

12. svn checkout http://libyuv.googlecode.com/svn/trunk libyuv-read-only

這時你的 bindings/JNI 目錄下會有以下目錄
libogg-1.3.0/
libvorbis-1.3.3/
libvpx/
libwebm/

13. Change current directory to <project>/jni

14. Create Application.mk with the data below

APP_ABI := armeabi-v7a
APP_OPTIM := release
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti


15. Create Android.mk with the data below

WORKING_DIR := $(call my-dir)
BINDINGS_DIR := $(WORKING_DIR)/bindings/JNI
include $(BINDINGS_DIR)/Android.mk


16. ndk-build -C <path to project>

大功告成, 你會在你的<project>/lib/armeabi-v7a 下看到  libvpx.so 等檔案
如何測試 build 出來的 .so 可以用呢? 在 README.android 裡也有介紹
在 MainActivity onCreate 加入以下的 code 就可以了

int[] major = new int[2];
int[] minor = new int[2];
int[] build = new int[2];
int[] revision = new int[2];
MkvMuxer.getVersion(major, minor, build, revision);
String outStr = "libwebm:" + Integer.toString(major[0]) + "." +
                        Integer.toString(minor[0]) + "." + Integer.toString(build[0]) + "." +
                        Integer.toString(revision[0]);
TextView tv = new TextView(this);tv.setText(outStr);
setContentView(tv);

2013年3月18日 星期一

Install & start up nodejs on ubuntu


Download nodejs tar.gz from nodejs

$ unzip nodejs tar.gz
$ ./configure
$ sudo make install


That's it! You can do a little test to make sure that nodejs has been installed correctly

$ node -v


Now, we can add a simple server side source code named server.js like this

var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end('Hello Http');
});
server.listen(8080); 
and start up this simple server by

node server.js

opening a browser and navigating to http://localhost:8080

Here is a good beginners guide

2013年3月14日 星期四

Apache2 SSL and openssh and ufw for ubuntu

基本上參考這兩篇的作法就不會錯

How to Create a SSL Certificate on Apache for Ubuntu 12.04
Apache2 SSL in Ubuntu

不過在更改 VirtualHost 時, 應改為 <VirtualHost _default_:443>
否則會出現 ssl_error

安裝 openssh 只要下 apt-get install openssh-server 就可以了
修改 port 或 PermitRootLogin 等設定可以到 /etc/ssh/sshd_config

在安裝完以上兩個服務後, 可以開啟 ufw
sudo ufw enable
sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443

UPDATE:
如果有外掛 x-sendfile 模組也要記得在 /etc/apache2/sites-available/default-ssl
加入

 XSendFile on
 XSendFilePath  /file-path


如果希望使用者必須使用ssl存取某個目錄也可以在 /etc/apache2/sites-available/default
加入 Redirect permanent /ssl-dir https://server.name/ssl-dir 的方式重新導向

2013年1月31日 星期四

[Android] 波形分析APP

本 app 主要的目的是透過 以下三個音源

1. 手機麥克風

2. 藍芽耳機的麥克風

3. WAV 檔

產生即時的波形圖並提供 FIR 演算法濾波

顯示濾波後的波形圖,讀入的音源為 8BIT/16BIT PCM 格式







 

Python Tkinter First Example

import tkinter as tk def on_closing():     root.destroy() class MainWindow(tk.Tk):     def __init__(self, *args, **kwargs):         tk.Tk.__...