728x90

Oracle Connection Pool

		<Resource auth="Container" 
              driverClassName="oracle.jdbc.driver.OracleDriver" 
              factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" 
              maxActive="100" 
              maxIdle="30" 
              maxWait="10000" 
              name="jdbc/testDS" 
              password="tiger" 
              type="javax.sql.DataSource" 
              url="jdbc:oracle:thin:@loclahost:1521:orcl" 
              username="scott"/>

Context 경로 추가

		<Context docBase="C:/workspace/images" path="images" reloadable="true"/>

URIEncoding

		<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8"/>
728x90
728x90

Spring Controller

@Controller
@RequestMapping(value = "/form/mfile_add")
public class CMXFileAddController {

	@RequestMapping(method = RequestMethod.GET)
	public String getUploadForm(Model model) {
		MFile mFile = new MFile ();
		model.addAttribute("mFile", mFile);
		return "/form/mfile_add";
	}

mfile_add.jsp

<form:form modelAttribute="mFile" method="post" enctype="multipart/form-data">

        <legend>자료 등록</legend>

        <table>
          <TR>
            <TD><form:label for="title" path="title">제목</form:label></TD>
            <TD><form:input path="title" type="text" size="85"/></TD>
          </TR>
          <TR>
            <TD><form:label for="file1" path="file1">파일1</form:label></TD>
            <TD><form:input path="file1" type="file" size="70"/></TD>
          </TR>
          <TR>
            <TD><form:label for="desc" path="desc">설명</form:label></TD>
            <TD><form:textarea path="desc" cols="84" rows="5" /></TD>
          </TR>
        </table>

        <input type="submit" value="등록"/>

</form:form>

Post 파일 업로드 처리

	@RequestMapping(method = RequestMethod.POST)
	public String create(MFile mFile, BindingResult result) {
		
		System.out.println(mFile);
		
		if (result.hasErrors()) {
			for (ObjectError error : result.getAllErrors()) {
				System.err.println("Error: " + error.getCode() + " - " + error.getDefaultMessage());
			}
			return "/form/mfile_add";
		}

		if (!mFile.getFile1().isEmpty()) {
			String filename = mFile.getFile1().getOriginalFilename();
			String imgExt = filename.substring(filename.lastIndexOf(".") + 1, filename.length());

			// upload 가능한 파일 타입 지정
			if (imgExt.equalsIgnoreCase("xls")) {
				byte[] bytes = mFile.getFile1().getBytes();
				try {
					File lOutFile = new File(fsResource.getPath() + filename  + "_temp.xls");
					FileOutputStream lFileOutputStream = new FileOutputStream(lOutFile);
					lFileOutputStream.write(bytes);
					lFileOutputStream.close();
				} catch (IOException ie) {
					// Exception 처리
					System.err.println("File writing error! ");
				}
				System.err.println("File upload success! ");
			} else {
				System.err.println("File type error! ");
			}
		
		}
		return "redirect:mfile_list.itg";
	}

 

728x90
728x90

출처 :
http://stackoverflow.com/questions/10496912/convert-date-from-json-format-to-other-formats-in-sencha
http://stackoverflow.com/questions/7848369/sencha-touch-date-format

소스

  Ext.regModel('dataModel', {
      fields: [
         {name: 'id', type: 'int'},
         {name: 'vod_id', type: 'int'},
         {name: 'comment', type: 'string'},
         {name: 'regid', type: 'string'},
         {name: 'regdate', type:'date', dateFormat: 'c'}
      ]
  });

  dataList = new Ext.List({
      title: 'VodComment목록',
      store: dataStore,
      scroll: false,
      layout:'fit',
      blockRefresh:true,
      itemTpl:'{comment} {regid} / {regdate:date("Y.m.d H:i:s")}'
  });

패턴

Date.patterns = {
    ISO8601Long : "Y-m-d H:i:s",
    ISO8601Short : "Y-m-d",
    ShortDate : "n/j/Y",
    LongDate : "l, F d, Y",
    FullDateTime : "l, F d, Y g:i:s A",
    MonthDay : "F d",
    ShortTime : "g:i A",
    LongTime : "g:i:s A",
    SortableDateTime : "Y-m-d\\TH:i:s",
    UniversalSortableDateTime : "Y-m-d H:i:sO",
    YearMonth : "F, Y"
};
728x90
728x90

MySQL JDBC 연결

import java.sql.Connection;
import java.sql.DriverManager;

public class Test {
  public static void main(String[] args) throws Exception {
    Connection conn = null;
    try {
      Class.forName("org.gjt.mm.mysql.Driver"); 
      conn = DriverManager.getConnection("jdbc:mysql://localhost:5515/dbname?user=id&useUnicode=true&characterEncoding=UTF8", "id", "pw");
    } catch (Exception e) {
      e.printStackTrace();
      if (conn!=null) try { conn.close(); } catch (Exception e2) { }
    }
  }
}

Oracle thin

import java.sql.Connection;
import java.sql.DriverManager;

public class Test {
  public static void main(String[] args) throws Exception {
    Connection conn = null;
    try {
      Class.forName("oracle.jdbc.driver.OracleDriver"); 
      conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "scott", "tiger");
      
      System.out.println(conn);
      
    } catch (Exception e) {
      e.printStackTrace();
      if (conn!=null) try { conn.close(); } catch (Exception e2) { }
    }
  }
}

Oracle OCI

import java.sql.Connection;
import java.sql.DriverManager;

public class TestOCI {
  public static void main(String[] args) throws Exception {
    Connection conn = null;
    try {
      Class.forName("oracle.jdbc.driver.OracleDriver"); 
      conn = DriverManager.getConnection("jdbc:oracle:oci:@xe", "scott", "tiger");
      
      System.out.println(conn);
      
    } catch (Exception e) {
      e.printStackTrace();
      if (conn!=null) try { conn.close(); } catch (Exception e2) { }
    }
  }
}
728x90
728x90

Sencha1에서 Carousel에 여러개 등록하고,
scrollToCard로 이동해도 2개 이상 이동이 되지 않습니다.

내부적으로 2개 이상 이동시 속도 저하가 있어서 그렇게 해둔것인지는 모르겠지만,
override하면 sencha 소스 자체를 수정하지 않고, 전체에 반영되도록 할 수 있습니다.

처음에는 sencha 소스를 수정 했는데,
secha가 업그레이드 될 경우 다시 수정해야 되는 번거로움은 사라졌습니다.

Ext.override

Ext.override(Ext.Carousel, {
    isCardInRange : function(card) {
        //return Math.abs(this.getCardIndexOffset(card)) <= 2; // 2개 이상 이동 제한 코드
    	return true;
    }
});

이동 메소드(참조용)

      seek : function(index) {
		var oldCard = this.getActiveItem();
		var next = this.items.items[index];
        if (next) {
            this.customDrag = true;
            this.scrollToCard(next);
            //this.onCardSwitch(next, oldCard, index, true);
        }
        return this;
	},
728x90
728x90

Sencha에서 사용자 정의 이벤트를 만드는 방법을 정리해보았습니다.

객체 선언시 addEvents 메소드로 이벤트를 등록하고,
fireEvent 메소드로 이벤트 호출하고,
리스너에서 이벤트를 받아서 처리하면 됩니다.

이벤트 등록

this.addEvents('OnLoadImage');

이벤트를 리스너 등록

listeners: {
  OnLoadImage: function(panel, index, imgUrl) {
    //alert('ImageUrl' + src);
  }
}

이미지 번호로 이미지 URL 정보를 얻었을 경우 이벤트 호출

this.fireEvent('OnLoadImage', this, this.getActiveIndex(), imgUrl);

소스

Jarvus.mobile.PinchCarousel = Ext.extend(Ext.Carousel, {

  initComponent : function() {
    // shryu
    this.addEvents('OnLoadImage');
  },

  doLoadImage(imageNo) {
    Ext.Ajax.request({
      url : json_url,
      params : {
        cmd : 'getImageUrl',
        imgno : imageNo
      },
      success : function(response, opts) {
        var JsonData = JSON.parse(response.responseText);
        if (JsonData.data.err == "") {
          OnLoadImage(JsonData.data.imgUrl);
        } else {
          return false;
        }
      }
    });
  },

  // shryu
  OnLoadImage : function(imgUrl) {
    //alert('OnLoadImage = ' + this.getActiveIndex() + '/' + imgUrl);
    this.fireEvent('OnLoadImage', this, this.getActiveIndex(), imgUrl);
  }
}

var pinchCarousel = new Jarvus.mobile.PinchCarousel({
  listeners: {
    OnLoadImage: function(panel, index, imgUrl) {
      //alert('ImageUrl' + src);
    }
  }
});
728x90
728x90

ffmpeg 라이브러리를 이용해서 wowza서버를 사용하는 rtsp 플레이어를 제작해보았습니다.
소스는 iFrameExtractor 프로젝트에서 파일 오픈하는 부분을 rtsp 주소를 사용했고,
ffmpeg 라이브러리 경로를 따로 설정해서 컴파일 했습니다.

설치한 ffmpeg 라이브러리가 ios용으로 컴파일 되어 있어서
시뮬레이터에서는 테스트 할 수가 없네요.

iFrameExtractor 프로젝트는 ffmpeg 라이브러리만 사용했기 때문에 플레이는 되지만,
속도는 나오지 않습니다. OpenGL ES / SDL 라이브러리 이용해야 될 것 같네요.

출처

How can you pass YUV frames from FFmpeg to OpenGL ES?
TECH TUTORIAL ? HOW TO SETUP A SDL-READY XCODE4 PROJECT
CODEC_TYPE_VIDEO undefined
ffmpeg을 이용한 iOS 동영상 플레이어
<video> 태그를 이용하여 rstp 프로토콜의 스트리밍을 재생하고자 하고싶은데요...
Audio and Video HTML
myoutube or RTSP streaming support on chrome

소스 다운로드

jayrparro / iFrameExtractor

ffmpeg 라이브러리 경로 설정

오류 수정

CODEC_TYPE_VIDEO undefined 발생 한다면,
AVMEDIA_TYPE_VIDEO 로 수정

rtsp 주소 설정
iFrameExtractorAppDelegate.m

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	//self.video = [[VideoFrameExtractor alloc] initWithVideo:[Utilities bundlePath:@"sophie.mov"]];
    //self.video = [[VideoFrameExtractor alloc] initWithVideo:[Utilities bundlePath:@"oh.mp4"]];
    self.video = [[VideoFrameExtractor alloc] initWithVideo:@"rtsp://192.168.0.13/vod/mp4:sample.mp4"];
	[video release];

	// set output image size
	video.outputWidth = 426;
	video.outputHeight = 320;
	
	// print some info about the video
	NSLog(@"video duration: %f",video.duration);
	NSLog(@"video size: %d x %d", video.sourceWidth, video.sourceHeight);
	
	// video images are landscape, so rotate image view 90 degrees
	[imageView setTransform:CGAffineTransformMakeRotation(M_PI/2)];
    [window makeKeyAndVisible];
}

YUV 데이터 -> RGB 데이터 소스
VideoFrameExtractor.m

-(void)convertFrameToRGB {	
	sws_scale (img_convert_ctx, pFrame->data, pFrame->linesize,
			   0, pCodecCtx->height,
			   picture.data, picture.linesize);	
}

실행


728x90
728x90

출처

iOS용 FFmpeg 빌드
[iPhone] ffmpeg 빌드하기
How to cross compile ffmpeg for iOS (iPhone and iPad)
Build m4, autoconf, automake, libtool on Mac OS X Lion
http://www.slideshare.net/hypermin/html5-video

make 커맨드 설치

pkg-config 설치

pkg-config 다운로드

gas-preprocessor 다운로드

gas-preprocessor 다운로드

build-essentials 스크립트 다운로드및 실행

설치되는 항목 m4, autoconf, automake, libtool

https://gist.github.com/1397146

- 디렉토리구조

$HOME
├ local
└ Builds
   └ build-essential
      ├ build-essential.sh
      └ src

- 실행

$ chmod 755 build-essential.sh
$ ./build-essential.sh

- 경로 추가 (~/.profile)

PATH=$PATH:/Users/자신의계정/local/bin

- 확인

압축풀기

- 다운로드

ffmpeg 다운로드

- 압축풀기

$ tar xvfz ffmpeg-0.8.11.tar.bz2

config.sh 파일

./configure --enable-cross-compile \
  --arch=arm \
  --target-os=darwin \
  --cc='/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2' \
  --as='./gas-preprocessor/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2' \
  --cpu=cortex-a8 \
  --enable-pic \
  --disable-yasm \
  --sysroot='/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' \
  --extra-cflags='-mfpu=neon -pipe -Os -gdwarf-2 -miphoneos-version-min=5.0' \
  --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -miphoneos-version-min=5.0' \
  --disable-asm \
  --disable-doc \
  --disable-ffmpeg \
  --disable-ffplay \
  --disable-ffprobe \
  --disable-ffserver \
  --enable-avdevice \
  --disable-devices \
  --disable-filters \
  --disable-yasm \
  --enable-network \
  --enable-protocol=tcp \
  --enable-demuxer=rtsp \
  --enable-decoder=h264

$ ./config.sh

$ make

$ sudo make install

728x90

+ Recent posts